Make filenames from folder name

Started by mikaelkindt, October 10, 2015, 11:04:36 AM

Previous topic - Next topic

mikaelkindt

I'm new to Exiftool, and need some help.

My folders have correct names, and now I want to rename the files. I want the files in the folder "1999" to be renamed to "1999_001", "1999_002" and so on. Can someone please explain how?

Phil Harvey

Here is one command to do this:

exiftool "-filename<${directory;$_=substr($_,-4)}_%.3nc.%e" DIR

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mikaelkindt

Thanks for the quick reply :D I don't get it working though. Please se attached file. What am I doing wrong?

Also. I would like to use the folder name, e.g. 1980, for DateTimeCreated. I want the files in 1980 to to have DateTimeCreated 1980:01:01 00:00:00. In the folder 1980 there are subfolders, e.g. "aug-sep", but I want exiftool to use 1980 even for files in subfolders.

How to? Is there a command line that would make it possible to drag the folder containing all the folders 1980, 1981 etc. to terminal/exiftool and have these actions performed?

Thanks again
Mikael

Hayo Baan

#3
Since you're on a Mac, change the double quotes to single quotes and it'll work :)

As for your second question, you can not change the datetime created (with exiftool) on a Mac as far as I know, I would advise against that anyway as that is a filesystem tag and can get changed without intention easily. Why not use e.g., the exif tag DateTimeOriginal? You could write this e.g., like this:
exiftool '-DateTimeOriginal<${directory;$_=substr($_,4)}01:01 00:00:00' DIR
This wouldn't work on your subdirectories though, you'll need to get more fancy for that...
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

Just FYI:

There is a mechanism to indirectly set the file creation date on OS X...

From the Extra Tags documentation:

Note that although ExifTool can not currently access the filesystem creation time on other systems, the creation time is pushed backwards on OS X by writing an earlier modification time, which provides a mechanism to write this indirectly: 1) Rewrite the file to set the filesystem creation and modification times to the current time, 2) Set FileModifyDate to the desired creation time, then 3) Restore FileModifyDate to its original

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).