-
Notifications
You must be signed in to change notification settings - Fork 0
Built in variables
F2 provides several built-in several variables that can be utilised in the replacement string.
These variables help you access the original filename before replacement. They can come in handy if you want to add a prefix or a suffix to a set of files.
-
{{f}}
: the original filename (excluding the extension). -
{{p}}
: the parent directory name. -
{{ext}}
: the file extension (including the.
).
Example
Assuming the following directory structure:
house-chores/
├── cleaning.md
├── laundry.md
├── mowing.md
└── washing.md
A renaming operation may be performed by prefixing the directory's name into the new names:
$ f2 -r "{{p}}_{{f}}{{ext}}"
+-------------+--------------------------+--------+
| INPUT | OUTPUT | STATUS |
+-------------+--------------------------+--------+
| cleaning.md | house-chores_cleaning.md | ok |
| laundry.md | house-chores_laundry.md | ok |
| mowing.md | house-chores_mowing.md | ok |
| washing.md | house-chores_washing.md | ok |
+-------------+--------------------------+--------+
The time attributes of a file can be used in the replacement string. F2 provides variables that enable you to access the file creation time, modification time, access time and more.
-
ctime
: The time at which file metadata was changed. -
btime
: File birth time (Windows and macOS only). -
atime
: The last time the file was accessed or read. -
mtime
: The last time the contents of the file was modified. -
now
: The current time.
The above variables must be combined with a date token (seen below)
Token | Explanation | Output |
---|---|---|
YYYY | Year represented by a full four digits | 1970 1971 ... 2029 2030 |
YY | Year represented only by the last two digits | 70 71 ... 29 30 |
MMMM | Name of the month | January February ... November December |
MMM | Abbreviated name of the month | Jan Feb ... Nov Dec |
MM | Month as digits with leading zeros for single-digit months | 01 02 ... 11 12 |
M | Month as digits without leading zeros for single-digit months | 1 2 ... 11 12 |
DDDD | Name of the day of the week | Monday Tuesday ... Saturday Sunday |
DDD | Abbreviated name of the day of the week | Mon Tue ... Sat Sun |
DD | Day of the week as digit with leading zeros | 01 02 ... 06 07 |
D | Day of the week as digit without leading zeros | 1 2 ... 6 7 |
H | 24 Hours clock | 01 02 ... 22 23 |
hh | Hours with leading zeros for single-digit hours | 01 02 ... 11 12 |
h | Hours without leading zeros for single-digit hours | 1 2 ... 11 12 |
mm | Minutes with leading zeros for single-digit minutes | 01 02 ... 58 59 |
m | Minutes without leading zeros for single-digit minutes | 1 2 ... 58 59 |
ss | Seconds with leading zeros for single-digit seconds | 01 02 ... 58 59 |
s | Seconds without leading zeros for single-digit seconds | 1 2 ... 58 59 |
A | AM PM | AM PM |
a | am pm | am pm |
Example
$ f2 -f 'screenshot' -r '{{mtime.MMM}}-{{mtime.DD}}-{{mtime.YYYY}}-screenshot'
+----------------+----------------------------+--------+
| INPUT | OUTPUT | STATUS |
+----------------+----------------------------+--------+
| screenshot.jpg | Nov-08-2020-screenshot.jpg | ok |
| screenshot.png | Mar-04-2021-screenshot.png | ok |
+----------------+----------------------------+--------+
Important: this feature only works for JPEG, DNG, and most other RAW image formats (CR2, NEF, RAF, ARW, e.t.c.). HEIC/HEIF is not supported at the moment.
The exif attributes of an image file can be used in its replacement string. F2
provides variables that enable you to access the ISO, width, height, created
date, aperture, model, make, dimensions, focal length and exposure time for
images. Each variable can be used like this: {{exif.<var>}}
as in
{{exif.iso}}
. If an exif attribute is not present in the image file, the
corresponding variable will be replaced with an empty string.
Currently supported variables:
-
iso
: The ISO at which the image was captured. -
w
: The image width. -
h
: The image height. -
model
: The camera model (e.g. Canon EOS 5D Mark III). -
make
: The camera maker (e.g. Canon). -
lens
: The lens model. -
et
: The exposure time (e.g. 1/400s). -
wh
: The image dimensions (e.g 4032x3024). -
fnum
: The aperture (e.g. f/1.6). -
fl
: The focal length of the lens (e.g 52mm) -
dt
: The image creation date. This must be combined with a date token (e.g{{exif.dt.YYYY}}
).
Example
f2 -f "proraw.dng" -r "{{exif.model}}_{{exif.fl}}_{{exif.et}}_{{exif.wh}}_{{f}}{{ext}}"
+------------+-----------------------------------------------------+--------+
| INPUT | OUTPUT | STATUS |
+------------+-----------------------------------------------------+--------+
| proraw.dng | iPhone 12 Pro Max_5.1mm_1_121s_4032x3024_proraw.dng | ok |
+------------+-----------------------------------------------------+--------+
More variables coming soon