Author Topic: Subfolder based on the data found?  (Read 111 times)

xhaloz

  • Newbie
  • *
  • Posts: 8
Subfolder based on the data found?
« on: April 11, 2019, 10:22:46 AM »
Hello, easy question/answer (I hope).  For pictures I use the following statement,

Code: [Select]
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

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14438
    • ExifTool Home Page
Re: Subfolder based on the data found?
« Reply #1 on: April 11, 2019, 10:39:47 AM »
Try this:

Code: [Select]
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
« Last Edit: April 11, 2019, 12:11:12 PM by Phil Harvey »
...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 ($).

xhaloz

  • Newbie
  • *
  • Posts: 8
Re: Subfolder based on the data found?
« Reply #2 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!!!!!

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14438
    • ExifTool Home Page
Re: Subfolder based on the data found?
« Reply #3 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
...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 ($).

xhaloz

  • Newbie
  • *
  • Posts: 8
Re: Subfolder based on the data found?
« Reply #4 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?

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14438
    • ExifTool Home Page
Re: Subfolder based on the data found?
« Reply #5 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
...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 ($).

xhaloz

  • Newbie
  • *
  • Posts: 8
Re: Subfolder based on the data found?
« Reply #6 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


Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14438
    • ExifTool Home Page
Re: Subfolder based on the data found?
« Reply #7 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:

Code: [Select]
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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

xhaloz

  • Newbie
  • *
  • Posts: 8
Re: Subfolder based on the data found?
« Reply #8 on: April 11, 2019, 12:15:18 PM »
This is perfect!!!!  You're the best.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14438
    • ExifTool Home Page
Re: Subfolder based on the data found?
« Reply #9 on: April 11, 2019, 12:18:04 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, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).