Continuing the recovery that started in MY 2020/21 following two years of extreme drought. Canola production is forecast in MY 2021/22 at 3.9 million metric tons (MMT), only a 100,000-MT decline from a bumper crop in MY 2020/21. Although yields are expected to fall from the record levels of MY. Spaces in file names aren't usually a problem for modern systems, but you might want to consider these potential issues when creating your file naming guidelines. I try to balance this with ease of use and readability, and typically use spaces in file names. But again, this is a matter of personal preference.
Writing 'FileName' and 'Directory' tags
By writing the FileName and/or Directory pseudo tags, ExifToolcan be used to rename and/or move images into directories according to anyinformation contained in the image. This is a powerful feature when combinedwith the -tagsFromFile
ability to copy the values from other tags. The most common use of this feature is to organize images by date/time, but anyother tag value may also be used.
- Versions this guide is based on: EVE Image Name Downloaded Filename Version vCPUs vRAM HDD Format Console; extremexos-22.4.1.4: EXOS-VMv22.4.1.4-disk1.
- UltraStudio 4K Extreme 3 is the world’s most advanced capture and playback solution for PCI Express and Thunderbolt computers! It features incredibly fast 40Gb/s Thunderbolt 3, advanced 12G‑SDI and HDMI 2.0 connections for working at up to 60 frames per second with deep color, 12‑bit RGB, support for HDR workflows via HDMI 2.0a and extremely large 4K frame sizes.
Writing the Directory tag moves a file to a specified directory. Thedirectory is created if it doesn't already exist.
Writing the FileName tag renames a file. If the new FileNamehas a directory specification (ie. contains a '/
' character), thenthe file is also moved to the specified directory (seeexample 6 below), and the directory is created if necessary.Existing files will not be overwritten (but see 'Warning' below).
The write-only TestName tag provides a mechanism for dry-run testingof the rename feature. Writing TestName displays the old and new nameswithout making any changes to the files. (Note that there is no correspondingtest tag for Directory, but TestName supports a full path namejust like FileName, so the directory may be tested as well.)
When writing the FileName, Directory or TestName tag,%d
, %f
and %e
may be used to representthe directory, name and extension of the original file (in a similar way to the-o
, -w
and -tagsFromFile
options). Also,%c
may be used to add a copy number to the output file name toavoid collisions with existing file names. Note that these codes must be escapedwith an extra %
if used within a date format string. Modifiers mayalso be used to change the default behaviour of these format codes. See the-w
option in the applicationdocumentation for details.
When organizing files by date/time, the -d
(date format) optionis essential for specifying a format for the date/time tag(s) used to generatethe new file and/or directory name. The examples below demonstrate the use ofthis feature. Also, a list of of common date format codesis provided for reference.
Advanced feature: The write-onlyHardLink tag may be written using a technique similar to FileName.Instead of renaming or moving the file, writing HardLink creates a hardlink with the specified name. This feature allows files to be organized withoutaffecting the originals. See the Extra Tagsdocumentation for more information.
Notes:
Writing the FileName and/or Directory tags alone causes thefile to be renamed or moved, not copied. However, if any 'real' tags arewritten at the same time, then the file is rewritten to the new destination andthe original file is left unchanged. (Only writable system tags may be setwithout causing the file to be rewritten.) If desired, the-overwrite_original
option may be used to remove the original copywhen the file is rewritten.
Conversely, the -o
option may be used to force exiftool toalways create a copy of the file, even if no meta-information tags are written. This is true even if the -o
option is superseded by writing theDirectory tag, or through a FileName which includes a directoryspecification. (See example 5 below. Also seeexample 11 for the directory precedence rules.)
If the -d
option is used, the unformatted date/time value mustbe valid (ie. in the form 'YYYY:mm:dd HH:MM:SS
'), otherwise thedate formatting will fail and the file will not be renamed or moved (but this maybe changed via the API StrictDate option).
Also note that the -d
formatting applies to date/time tags usedin -if
conditions unless the print conversion is disabled by addinga #
suffix to the tag name.
In a Windows batch file, all %
characters must be escaped as%%
. This can result in extreme format codes like%%%%f
when using the -d
option.
Warning:Writing illegal file names in Windows can have unpredictable results andmay result in data loss. Illegal characters in Windows file names are:Any tag used in generating a file name which may contain these characters mustfirst be filtered to remove or translate these characters. A special featureallows these characters to be removed from a tag value by adding a semicoloninside the braces after a tag name. For example:This advanced formatting feature may also be used to do arbitrary reformattingof any tag value used in a format string. See the -p
option in theapplication documentation for more details.
Examples
0. | exiftool -d %Y%m%d_%H%M%%-c.%%e '-testname<CreateDate' DIR |
The TestName tag is used for dry-run testing of the file renamingfeature. The above command is identical to that of the next example except thatTestName is written instead of FileName. So instead of renamingthe files, this command prints the old and new file names without actuallychanging anything. For example:
1. | exiftool -d %Y%m%d_%H%M%%-c.%%e '-filename<CreateDate' DIR |
DIR
' to names like'20060327_1058-2.jpg
', with individual file names derived from thevalue of the CreateDate (plus a copy number with a leading '-
' if afile with the same name already exists), and with the same extension as theoriginal image. [Note that copying tag values with '<
' implies'-tagsfromfile @
' unless otherwise specified. See the-tagsFromFile
description in theapplication documentation for details.]FAQ:'Why doesn't this command rename my files?'
There are 2 common reasons for this:
a) When a directory name is specified, this command will only rename 'writable'files in the directory. Use 'exiftool -listwf
' to list theextensions of currently writable file types. The -ext
option maybe used to rename other file types (eg. '-ext avi
').
b) For this command to work, the CreateDate tag must exist in the sourcefile. Use 'exiftool -createdate FILE
' to see if a file containsthis information. If it doesn't, you may need to use another date/time tag suchas DateTimeOriginal or FileModifyDate. To see all available date/time tags in afile (and their locations), use 'exiftool -a -G1 -s -time:all FILE
'.
2. | exiftool -d %Y-%m-%d '-directory<datetimeoriginal' image.jpg |
Move 'image.jpg
' into a directory with a name given byDateTimeOriginal, in the form '2006-03-27
'.
3. | exiftool '-filename<%f_$imagesize.%e' dir |
This example uses an expression to add the image size to the name of all imagesin directory 'dir
'. For example, this would rename a 640x480 imagecalled 'image.jpg
' to 'image_640x480.jpg
'. (Note thatthe single quotes are necessary in Unix shells due to the '$
'symbol, but double quotes must be used instead when running in a Windows cmd shell.)
4. | exiftool -r -directory=%e_images/%d pics |
Recursively move all images based in directory 'pics
' toseparate directory trees organized by file extension. For instance, in thisexample the file 'pics/toys/new_car.jpg
' is moved to'jpg_images/pics/toys/new_car.jpg
'.
5. | exiftool -r -o %e_images/%d pics |
Both of these commands have the same effect as example 4 above except thatimages are copied instead of moved since the-o
option was used.The output directory specified by the-o
option is overridden inthe second example by writing the Directory tag. This technique of using-o
with a dummy directory name is necessary when you want the filesto be copied instead of moved and the directory name is derived from the valueof other tags (eg. '-directory<createDate
'). (Because thevalues of other tags may not be used with the-o
option.)
6. | exiftool -r -d %Y/%m/%d/image_%H%M%S.%%e '-filename<filemodifydate' DIR |
Recursively rename all images in 'DIR
' and any containedsubdirectories to the form 'image_HHMMSS.EXT
' (where'ext
' is the original file extension), and move them into a newdirectory hierarchy based on date of file modification, with path names like'2006/03/27/image_105859.jpg
'.
The following examples demonstrate the interaction of this feature withother ExifTool options:
7. | exiftool -filename=new.jpg dir/image.jpg |
Rename 'dir/image.jpg
' to 'dir/new.jpg
'.
8. | exiftool -filename=new.jpg -comment=xxx dir/image.jpg |
Copy 'dir/image.jpg
', add a new comment, and write output to'dir/new.jpg
'. The original file 'dir/image.jpg
' isnot changed.
9. | exiftool -filename=new.jpg -comment=xxx -overwrite_original dir/image.jpg |
Rewrite 'dir/image.jpg
', adding a new comment and writing output to'dir/new.jpg
'. The original file 'dir/image.jpg
' isremoved.
10. | exiftool -o tmp/ -filename=new.jpg image.jpg |
A file name or directory specified via the FileName or Directorytag takes precedence over that specified by the-o
option, so thesethree commands all have the same effect: 'tmp/new.jpg
' is createdwithout changing 'image.jpg
'. Note that in the first command, thetrailing '/
' on 'tmp/
' is necessary if the'tmp
' directory doesn't already exist, otherwise 'tmp
'would be taken as a file name and 'new.jpg
' would be created in thecurrent directory. As illustrated in example 4 above, the file is rewritteninstead of simply being renamed when the '-o
' option is used.
11. | exiftool -directory=dir1 -filename=dir2/out.jpg -o dir3/ dir4/image.jpg |
This example demonstrates the priorities of directory names specified usingdifferent techniques. The output directory is taken from the first directoryspecified from the following list: 1) the Directory tag, 2) thedirectory part of the FileName tag, 3) the directory part of the-o
option, or 4) the source directory, in that order. The order ofthe arguments on the command line is not significant. In this example, thetarget file is copied (not moved, because the-o
option was used)to 'dir1/image.jpg
'.
Note that both the FileName tag and the-o
option may be used without a directory specification, in which case thedirectory with the next highest priority is used. Also note that if-o
specifies a directory, then the directory name must end with a'/
' or the directory must already exist, otherwise ExifTool willinterpret the last part as a file name. (eg. '-o images/test
'specifies the 'images
' directory unless the'images/test
' directory already exists, while '-oimages/test/
' unambiguously specifies the 'images/test
'directory.)
12. | exiftool -d %Y/%m '-directory<filemodifydate' '-directory<createdate' '-directory<datetimeoriginal' . |
Move image files from the current directory (.
) into adirectory hierarchy based on year/month. In this command the Directory tag isset from multiple other date/time tags. ExifTool evaluates the command-linearguments left to right, and latter assignments to the same tag override earlierones, so the Directory for each image is ultimately set by the rightmost copyargument that is valid for that image. Specifically, Directory is set fromDateTimeOriginal if it exists, otherwise CreateDate if it exists, and finallyFileModifyDate (which always exists) is used as a fallback.
Common Date Format Codes
Date format codes are used in the argument to the -d
option torepresent components of the date/time string. The codes listed below are commonto most systems, but additional codes may be available on your specific system-- see your strftime man page for details. The default EXIF date/timeformatting is equivalent to '%Y:%m:%d %H:%M:%S
'.
Filename Extension Heic
%a | - abbreviated locale weekday name |
---|---|
%A | - full locale weekday name |
%b | - abbreviated locale month name |
%B | - full locale month name |
%c | - preferred locale date/time representation |
%d | - day of month (01-31) |
%H | - hour on a 24-hour clock (00-23) |
%I | - hour on a 12-hour clock (01-12) |
%j | - day of year (001-366) |
%m | - month number (01-12) |
%M | - minute (00-59) |
%p | - 'AM' or 'PM' |
%s | - number of seconds since the Epoch, UTC (see note 1 below) |
%S | - seconds (00-59) |
%w | - weekday number (0-6) |
%W | - week number of the year (00-53) |
%x | - preferred locale date representation |
%X | - preferred locale time representation |
%y | - 2-digit year (00-99) |
%Y | - 4-digit year (eg. 2006) |
%z | - time zone in the form +/-hhmm (see note 1 below) |
%Z | - system time zone name (see note 2 below) |
%% | - a literal '%' character |
ExifTool file name format codes may be used inside a date formatstring when a date/time tag is used to set the value of the FileName orDirectory tags via the command-line interface. In this case, an extra'%
' must be added to pass the format code through the date/timeparser:
%%d | - original file directory (including trailing '/' if necessary) |
---|---|
%%f | - original file name (without the extension) |
%%e | - original file extension (not including the '.') |
%%c | - copy number (output files only) |
Filename Extractor
See the -w
option in the exiftoolapplication documentation for details about special features availablewith these name format codes.
Notes:
Filename Extreme Pro
- The %s and %z format codes use the time zone specified by the date/timevalue. If the date/time value does not include a time zone specification, thenit is interpreted as a local time in the system time zone. These format codesare parsed by ExifTool, so they should work on all systems.
- The %Z format code ignores any time zone specified in the date/time value,and returns the system time-zone name for the given date/time interpreted as alocal system time.