File Pair Renaming
A file pair refers to two or more files located in the same folder that differ only by their extension. For example, the following is a file pair:
image_001.dng
image_001.jpg
image_001.hif
image_001.xmp
File pairs are common when dealing with image files, such as RAW and JPEG files generated by cameras, or different formats like HIF or XMP metadata files. Video file pairs are also common, with multiple formats being generated for the same video.
F2 offers a pair renaming feature that allows you to rename all files in a pair consistently using the -p/--pair
option.
You can use pair renaming to apply the same naming scheme across all file formats in the pair:
f2 -r "Wedding_{x.cdt.YYYY}{x.cdt.MM}{x.cdt.DD}_{%03d}" -p
Output:
*——————————————*——————————————————————————*————————*
| ORIGINAL | RENAMED | STATUS |
*——————————————*——————————————————————————*————————*
| DSC09137.arw | Wedding_20241013_001.arw | ok |
| DSC09137.hif | Wedding_20241013_001.hif | ok |
| DSC09137.jpg | Wedding_20241013_001.jpg | ok |
| DSC09138.arw | Wedding_20241013_002.arw | ok |
| DSC09138.hif | Wedding_20241013_002.hif | ok |
| DSC09138.jpg | Wedding_20241013_002.jpg | ok |
*——————————————*——————————————————————————*————————*
In this case, the file pairs are preserved, and each file in the pair (RAW, JPEG, HIF) is renamed consistently with the same pattern.
If the -p
option is not used, the results will not preserve the relationship between the files:
*——————————————*——————————————————————*————————*
| ORIGINAL | RENAMED | STATUS |
*——————————————*——————————————————————*————————*
| DSC09137.arw | Wedding_20241013_001 | ok |
| DSC09137.hif | Wedding__002 | ok |
| DSC09137.jpg | Wedding_20241013_003 | ok |
| DSC09138.arw | Wedding_20241013_004 | ok |
| DSC09138.hif | Wedding__005 | ok |
| DSC09138.jpg | Wedding_20241013_006 | ok |
*——————————————*——————————————————————*————————*
You'll notice that the file pairs are no longer preserved, and the HIF
files are missing the creation date. That's because F2's exif variables do not currently support HIF/HEIC files (you can try the Exiftool integration instead).
Notes
- In pair renaming mode, file extensions are automatically preserved, so you don't need to use the
-e/--ignore-ext
option or specify the{ext}
variable.
Pair Renaming Order
In some cases, certain variables may not be available in all files within a pair. By default, F2 will extract variables from the first file in the pair, which can lead to issues if the file format does not support the required metadata.
For example, renaming .hif
and .jpg
pairs without specifying a renaming order might produce incomplete results, as seen below:
f2 -r "Wedding_{x.cdt.YYYY}{x.cdt.MM}{x.cdt.DD}_{%03d}" -p
Output:
*——————————————*——————————————————*————————*
| ORIGINAL | RENAMED | STATUS |
*——————————————*——————————————————*————————*
| DSC09137.hif | Wedding__001.hif | ok |
| DSC09137.jpg | Wedding__001.jpg | ok |
| DSC09138.hif | Wedding__002.hif | ok |
| DSC09138.jpg | Wedding__002.jpg | ok |
*——————————————*——————————————————*————————*
While the file pair is preserved, the {x.cdt.*}
variables are missing because F2 attempted to extract EXIF data from the .hif
files which do not support it.
You can specify the order in which file types are processed for variable extraction using the --pair-order
option. This ensures that variables are extracted from the correct file type and applied to the entire pair.
f2 -r "Wedding_{x.cdt.YYYY}{x.cdt.MM}{x.cdt.DD}_{%03d}" -p --pair-order 'jpg,hif'
Output:
*——————————————*——————————————————————————*————————*
| ORIGINAL | RENAMED | STATUS |
*——————————————*——————————————————————————*————————*
| DSC09137.jpg | Wedding_20241013_001.jpg | ok |
| DSC09137.hif | Wedding_20241013_001.hif | ok |
| DSC09138.jpg | Wedding_20241013_002.jpg | ok |
| DSC09138.hif | Wedding_20241013_002.hif | ok |
*——————————————*——————————————————————————*————————*
By specifying --pair-order 'jpg,hif'
, F2 now correctly extracts the EXIF data from the .jpg
files and applies the new naming scheme to both the .jpg
and .hif
files in the pair.