ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: xhaloz on April 11, 2019, 10:22:46 AM

Title: Subfolder based on the data found?
Post by: xhaloz on April 11, 2019, 10:22:46 AM
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!
Title: Re: Subfolder based on the data found?
Post by: Phil Harvey on April 11, 2019, 10:39:47 AM
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
Title: Re: Subfolder based on the data found?
Post by: xhaloz on April 11, 2019, 10:56:26 AM
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!!!!!
Title: Re: Subfolder based on the data found?
Post by: Phil Harvey on April 11, 2019, 11:01:44 AM
Use ' instead of " if you are on Linux (see my signature).

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

- Phil
Title: Re: Subfolder based on the data found?
Post by: xhaloz on April 11, 2019, 11:36:05 AM
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?
Title: Re: Subfolder based on the data found?
Post by: Phil Harvey on April 11, 2019, 11:41:33 AM
Could you give me an example of the format for the file name that you want?

- Phil
Title: Re: Subfolder based on the data found?
Post by: xhaloz on April 11, 2019, 11:57:37 AM
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

Title: Re: Subfolder based on the data found?
Post by: Phil Harvey on April 11, 2019, 12:07:26 PM
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
Title: Re: Subfolder based on the data found?
Post by: xhaloz on April 11, 2019, 12:15:18 PM
This is perfect!!!!  You're the best.
Title: Re: Subfolder based on the data found?
Post by: Phil Harvey on April 11, 2019, 12:18:04 PM
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