ExifTool Forum

ExifTool => Newbies => Topic started by: mikaelkindt on October 10, 2015, 11:04:36 AM

Title: Make filenames from folder name
Post by: mikaelkindt on October 10, 2015, 11:04:36 AM
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?
Title: Re: Make filenames from folder name
Post by: Phil Harvey on October 10, 2015, 08:48:42 PM
Here is one command to do this:

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

- Phil
Title: Re: Make filenames from folder name
Post by: mikaelkindt on October 11, 2015, 03:30:37 AM
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
Title: Re: Make filenames from folder name
Post by: Hayo Baan on October 11, 2015, 03:56:19 AM
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...
Title: Re: Make filenames from folder name
Post by: Phil Harvey on October 11, 2015, 05:59:31 PM
Just FYI:

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

From the Extra Tags documentation (https://exiftool.org/TagNames/Extra.html):

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