Welcome to Vifm Q&A, where you can ask questions about Vifm usage. Registration is optional, anonymous posts are moderated. GitHub or Google logins are enabled.

How to work with (select, rename) sidecar files based on the file name?

0 votes
asked Jan 22 in vifm by aleksejrs
edited Jan 25 by aleksejrs

https://en.wikipedia.org/wiki/Sidecar_file

Since there are many extensions, and the selected file can both be a sidecar file and have a sidecar file, I imagine keys/commands to switch between groups with deeper (more extensions ignored) and shallower levels (more sections of the file name are considered distinguishing) of extension nesting.

A group could be:

  • video.webm
  • video.webm.nordlicht.png (nordlicht file for the video)
  • video.png (thumbnail for the video)
  • video.png.xmp (metadata for the thumbnail)

When the current file is video.png, decreasing depth would switch to selecting only video.png and video.png.xmp.

A possible different mode with an explanation for the above: when multiple files are tagged, each one could have its own depth tracked separately, with the originally tagged files always remembered to re-calculate the selections.

1 Answer

0 votes
answered Jan 24 by xaizek

As of now there is only :select (:select video.* or more universal and less readable :execute 'select '.expand('%c:r').'*') and :unselect commands that can help with it. Once selected, usual bulk renaming should help with renaming.

The idea in general seems useful, although needs figuring out more details (should all files be in the same directory or not, what to do with user unselecting files that were selected automatically, and alike).

Is group always defined by a matching base name? E.g. in the example if video.webm was used to select 4 files, changing selection via video.png would imply that webm file is considered part of video.png group and gets unselected completely (otherwise it would cause selection of video.nordlicht.png).

commented Jan 25 by aleksejrs

video.nordlicht.png

Sorry, it should be video.webm.nordlicht.png.

commented Jan 25 by aleksejrs

This group uses "video.jpg" as the base:

  • video.jpg
  • video.jpg.xmp

It can be selected (the base can be chosen) with either of:

  • video.jpg and depth = 0 (maybe depth could be called the "degree of generalization")
  • video.jpg.xmp and depth = 1

This group uses "video" as the base:

  • video.webm
  • video.webm.nordlicht.png
  • video.jpg
  • video.jpg.xmp

It can be selected with either of:

  • video.webm or video.jpg and depth = 1
  • video.jpg.xmp and depth = 2
  • video.webm.nordlicht.png and depth = 3
commented Jan 25 by xaizek

Thanks, so the base is dynamic. Can there be many independent groups at the same time?

I'm trying to figure out how to resolve situation when you select all four files with one file and then select sub-group within that. State of previously selected "group leader" should be somehow changed/transferred in this case probably.

commented Jan 26 by aleksejrs
edited Jan 26 by aleksejrs

Can there be many independent groups at the same time?

Yes, that's the "possible different mode" in my original post.

I'm trying to figure out how to resolve situation when you select all four files with one file and then select sub-group within that.

Do you mean this, based on http://q2a.vifm.info/234/how-work-with-select-rename-sidecar-files-based-the-file-name?show=237#c237 :

  1. Select video.webm.
  2. depth = 1, which selects 4 files automatically.
  3. Unselect video.webm and video.webm.nordlicht.png.
    4a. Move the cursor to video.jpg.
    5a. depth = 0.
    4b. Move the cursor to video.jpg.xmp.
    5b. depth = 1.

(This is not a suggestion, I am just trying to imagine what you might mean.)

commented Jan 26 by xaizek

I was thinking in terms of "possible different mode" and meant something like this:

  1. Select video.webm and depth = 1, four files get selected.
  2. Select video.jpg and depth = 0, the same four files are selected, but video.jpg and video.jpg.xmp are as if selected twice.
  3. Unselect video.jpg, but selection doesn't change at all.

This just has confusing effects and probably requires some indication or something else.

If you would like to make a bug report or feature request consider using GitHub, SourceForge or e-mail. Posting such things here won't be considered as spam, but this is not a perfect place for it.
...