rename files with datetime and folder name

Started by Nexius2, June 04, 2018, 07:13:24 AM

Previous topic - Next topic

Nexius2

Hello,
I'm trying to rename my files with datetime and parent folder.  my problem comes from the structure of the parent directory. sometimes, it's just a description and sometimes I have a date in front in different format (YYYY-MM-DD or YYYY or YYYY-MM or YYYY-MM-DD-DD .... hope that's it). what I would like is to have only the description in the filename so if I have "./photo/2018-04 - sun/yellow.jpg" or "./photo/2018-04-02 sun/yellow.jpg" I would like "./photo/2018-04 - sun/2018-04-02_05-45-12 - sun.jpg"
this is where I am now. a bit of help would be helpfull

exiftool -d %Y-%m-%d_%H-%M-%S%%-c '-filename<${DateTimeOriginal;} - ${directory;s(.*/)()}.%le' -r .

Phil Harvey

Try this:

exiftool -d %Y-%m-%d_%H-%M-%S%%-c '-filename<${DateTimeOriginal} - ${directory;s(.*/)();s/^\d+.*? (- )?//}.%le' -r .

Here I am deleting any numbers up to the first space (with an optional "- " after that) from the start of the directory name.  I have also removed the ";" for DateTimeOriginal because this shouldn't be necessary.

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

Nexius2