News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Subfolder based on the data found?

Started by xhaloz, April 11, 2019, 10:22:46 AM

Previous topic - Next topic

xhaloz

Hello, easy question/answer (I hope).  For pictures I use the following statement,

exiftool -ext jpg -ext jpeg -ext png -ext jp2 -ext bmp -r -P -t -S -s -v -progress "-Filename<FileModifyDate" "-FileName<DateCreated" "-FileName<DateTimeOriginal" "-FileName<CreateDate" -d "../../MyMedia/Photos/%Y/%b/%Y-%m-%d %H.%M.%S%%-c.%%le" ./

Is there a way to have this line add a subfolder based on the exifdata that was found? 

To be clear, if FileModifyDate was the only data found on the file, the subfolder would be "Modified Date".  The same for DateCreated etc.

Thank you in advance!

Phil Harvey

#1
Try this:

exiftool -ext jpg -ext jpeg -ext png -ext jp2 -ext bmp -r -P -v -progress "-testname<../../MyMedia/Photos/Modified Date/$FileModifyDate" "-testname<../../MyMedia/Photos/Date Created/$DateCreated" "-testname<../../MyMedia/Photos/Date Time Original/$DateTimeOriginal" "-testname<../../MyMedia/Photos/Create Date/$CreateDate" -d "%Y/%b/%Y-%m-%d %H.%M.%S%%-c.%%le" .

(Note that I've removed -t -S -s from your command because these options are only valid when extracting metadata.)

If it does what you want, then replace "testname" with "filename" throughout to actually move/rename the files.

- Phil

Edit: Simplified command somewhat
...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 ($).

xhaloz

Ah, ok.  I am getting a bad substitution.  Does me using linux have anything to do with it?

Edit: Yes, changed double quotes to single and voila!  Thank you!!!!!

Phil Harvey

Use ' instead of " if you are on Linux (see my signature).

The command will rename and move the files in the same operation.

- 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 ($).

xhaloz

Phil, not to be a nuisance but how would I apply it to the filename itself now that I know how to do the directory?

Phil Harvey

Could you give me an example of the format for the file name that you want?

- 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 ($).

xhaloz

Yes

For modified as follows:
%Y/%b/%Y-%m-%d %H.%M.%S%-M%-c.%%le

Which would output
/2013/Jul/2013-07-13 09.20.50-M-1.jpg

Where the "M" would represent modified date if that was the only thing found for that file and the -1 would be an appendage if the file already existed for some reason


Phil Harvey

OK.  I've used the following codes:

-M for FileModifyDate
-D for DateCreated
-O for DateTimeOriginal
-C for CreateDate

The new format simplifies things somewhat since it comes after all of the date/time formatting.  Also, my original command was more complex than it needed to be (I'll simplify it in the previous post for future reference).

Try this:

exiftool -ext jpg -ext jpeg -ext png -ext jp2 -ext bmp -r -P -v -progress '-testname<${FileModifyDate}-M%-c.%le' '-testname<${DateCreated}-D%-c.%le' '-testname<${DateTimeOriginal}-O%-c.%le' '-testname<${CreateDate}-C%-c.%le' -d '../../MyMedia/Photos/%Y/%b/%Y-%m-%d %H.%M.%S' .

- 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 ($).

xhaloz

This is perfect!!!!  You're the best.

Phil Harvey

Quote from: xhaloz on April 11, 2019, 12:15:18 PM
You're the best.

If people keep telling me this, I can't be held responsible for the size of my ego... :P

- 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 ($).