Author Topic: Move to Directory  (Read 3937 times)

47u2caryj

  • Jr. Member
  • **
  • Posts: 10
Move to Directory
« on: March 20, 2016, 10:43:56 PM »
Hi,
I keep the Exiftool in the following directory.
D:\OneDrive\Documents\Software\ExifTool

I want to have a job that will move files from
D:\OneDrive\Pictures\Camera Roll

Into a different directory
D:\OneDrive\Pictures\Sorted\%Y\%m

I tried the following script but it keeps moving the files into the D:\OneDrive\Documents\Software\ExifTool directory
D:\OneDrive\Documents\Software\ExifTool>exiftool -ext jpg -d %Y-%m "-directory=D:\OneDrive\Pictures\Sorted" "-directory<datetimeoriginal" "D:\OneDrive\Pictures\Camera Roll"

Any help would be appreciated, thank you.

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2365
Re: Move to Directory
« Reply #1 on: March 20, 2016, 11:26:15 PM »
Try this (I think it's right, haven't tested it):
exiftool -ext jpg -d %Y-%m "-directory<D:\OneDrive\Pictures\Sorted\$datetimeoriginal" "D:\OneDrive\Pictures\Camera Roll"

What is happening is you have two Directory commands and the second one takes priority.  Since the second command isn't a full path, it's created relative to your current working directory, i.e. D:\OneDrive\Documents\Software\ExifTool.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

47u2caryj

  • Jr. Member
  • **
  • Posts: 10
Re: Move to Directory
« Reply #2 on: March 21, 2016, 11:20:43 PM »
Thanks,
That was close, the only change was to put a \ in between the year and month.
exiftool -ext jpg -d %Y\%m "-directory<D:\OneDrive\Pictures\Sorted\$datetimeoriginal" "D:\OneDrive\Pictures\Camera Roll"

47u2caryj

  • Jr. Member
  • **
  • Posts: 10
Re: Move to Directory with Task Scheduler
« Reply #3 on: March 24, 2016, 01:58:48 AM »
I have the working script that I can use with the command line:
exiftool -ext jpg -d %Y\%m "-directory<D:\OneDrive\Pictures\Sorted\$datetimeoriginal" "D:\OneDrive\Pictures\Camera Roll"

I created a *.txt file and changed the extension to *.cmd and when I run it it behaves differently than the manually.
Instead of putting the file in D:\OneDrive\Pictures\Sorted\2016\03 it puts the files in D:\OneDrive\Pictures\Sorted\m
the actual letter 'm'.

Why would it behave differently?
Does anyone have a suggestion for moving these files on a schedule if creating a *.cmd file won't work.

Thank you.

Hayo Baan

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 925
  • Professional Photographer & Software Developer
    • Hayo Baan – Photography
Re: Move to Directory
« Reply #4 on: March 24, 2016, 03:51:13 AM »
In Windows batch files, you need to double all your % characters :)
Hayo Baan – Photography
Web: www.hayobaan.nl

47u2caryj

  • Jr. Member
  • **
  • Posts: 10
Re: Move to Directory
« Reply #5 on: March 26, 2016, 01:52:39 AM »
Thank you this worked.

How can I assign files based on a date range.
I have decade directories above the years from the create date.

I was trying this:
D:\OneDrive\Documents\Software\ExifTool>exiftool -ext jpg -if "$datetimeoriginal ge '2010:01:01'" -d %Y/%m-%b "-directory<D:\OneDrive\Pictures\Camera Roll\2010s\$datetimeoriginal" -execute -if "$datetimeoriginal ge '2000:01:01'" and -if "$datetimeoriginal le '2010/01/01'" -d %Y/%m-%b "-directory<D:\OneDrive\Pictures\Camera Roll\2000s\$datetimeoriginal" "d:\OneDrive\Pictures\Camera Roll"

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14405
    • ExifTool Home Page
Re: Move to Directory
« Reply #6 on: March 26, 2016, 07:39:17 PM »
Close.  Try this:

exiftool -ext jpg -if "$datetimeoriginal ge '2010:01:01'" "-directory<D:\OneDrive\Pictures\Camera Roll\2010s\$datetimeoriginal" -execute -if "$datetimeoriginal ge '2000:01:01' and $datetimeoriginal lt '2010:01:01'" "-directory<D:\OneDrive\Pictures\Camera Roll\2000s\$datetimeoriginal" -common_args -d %Y/%m-%b  "d:\OneDrive\Pictures\Camera Roll"

Things I changed:

1. Added -common_args and moved the source directory to after this option to apply to both commands.

2. Moved -d %Y/%m-%b to after -common_args for simplicity

3. Changed slashes to colons in one of the dates.

4. Changed "le" to "lt" because the date should be less-than, not less-than-or-equal-to.

Also, remember to double the "%" characters if running in a Windows .bat file.

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

47u2caryj

  • Jr. Member
  • **
  • Posts: 10
Re: Move to Directory
« Reply #7 on: March 31, 2016, 02:37:37 PM »
Thank you this worked.
I will be back with further questions.
I appreciate the automation the tool provides.

47u2caryj

  • Jr. Member
  • **
  • Posts: 10
Assigning a Specific Date to All Date Fields
« Reply #8 on: April 04, 2016, 12:55:49 AM »
I created the following script to assign a specific date to all date fields.
First assigning the date to the -XMP:CREATEDATE and then across the other fields.
Looking for feedback to create greater efficiency since it lists the directory and -overwrite_original twice.
Thank you.

exiftool -overwrite_original -XMP:CREATEDATE="2010:01:01 00:00:00-06:00" "C:\...\pictures\2010" -execute -overwrite_original "-IPTC:DIGITALCREATIONDATE<XMP-XMP:CREATEDATE" "-IPTC:DIGITALCREATIONTIME<XMP-XMP:CREATEDATE" "-IPTC:DATECREATED<XMP-XMP:CREATEDATE" "-IPTC:TIMECREATED<XMP-XMP:CREATEDATE" "-XMP-EXIF:DATETIMEDIGITIZED<XMP-XMP:CREATEDATE" "-XMP-EXIF:DATETIMEORIGINAL<XMP-XMP:CREATEDATE" "-XMP-EXIF:GPSDATETIME<XMP-XMP:CREATEDATE" "-XMP-MICROSOFT:DATEACQUIRED<XMP-XMP:CREATEDATE" "-XMP-PHOTOSHOP:DATECREATED<XMP-XMP:CREATEDATE" "-XMP-XMP:MODIFYDATE<XMP-XMP:CREATEDATE" "-XMP:DATE<XMP-XMP:CREATEDATE" "-EXIF:DATETIMEORIGINAL<XMP-XMP:CREATEDATE" "-EXIF:CREATEDATE<XMP-XMP:CREATEDATE" "-EXIF:MODIFYDATE<XMP-XMP:CREATEDATE" "-MAKERNOTES:TIMESTAMP<XMP-XMP:CREATEDATE" "-GPS:GPSDATESTAMP<XMP-XMP:CREATEDATE" "-GPS:GPSTIMESTAMP<XMP-XMP:CREATEDATE" "-XMP-EXIF:GPSDATETIME<XMP-XMP:CREATEDATE" "C:\...\pictures\2010"

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14405
    • ExifTool Home Page
Re: Move to Directory
« Reply #9 on: April 04, 2016, 11:53:19 AM »
Why don't you just write the same value to the other tags instead of writing it to XMP:CreateDate then copying it to the others?

Also, it seems unnecessary to create all of these tags when many of them are seldom used.  You could use -wm w in a separate command to only update these types of tags if they already exist.

You can move the -overwrite_original and DIR to after -common_args at the end of the command line to simplify the command a bit, but this doesn't make it more efficient.

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

47u2caryj

  • Jr. Member
  • **
  • Posts: 10
Re: Move to Directory
« Reply #10 on: April 04, 2016, 02:45:41 PM »
Thanks for the feedback.
I'm unclear on the syntax, how to employee a specific value using -common_args

I've been trying variations of
exiftool -wm w -IPTC:DIGITALCREATIONDATE<"" -IPTC:DIGITALCREATIONTIME<"" ..... -common_args -d "2010:01:01 00:00:00-06:00" -overwrite_original DIR



Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14405
    • ExifTool Home Page
Re: Move to Directory
« Reply #11 on: April 04, 2016, 02:48:19 PM »
I was thinking of this:

exiftool -overwrite_original -XMP:CREATEDATE="2010:01:01 00:00:00-06:00" "-IPTC:DIGITALCREATIONDATE=2010:01:01 00:00:00-06:00" "-IPTC:DIGITALCREATIONTIME=2010:01:01 00:00:00-06:00" "-IPTC:DATECREATED=2010:01:01 00:00:00-06:00" "-IPTC:TIMECREATED=2010:01:01 00:00:00-06:00" "-XMP-EXIF:DATETIMEDIGITIZED=2010:01:01 00:00:00-06:00" "-XMP-EXIF:DATETIMEORIGINAL=2010:01:01 00:00:00-06:00" "-XMP-EXIF:GPSDATETIME=2010:01:01 00:00:00-06:00" "-XMP-MICROSOFT:DATEACQUIRED=2010:01:01 00:00:00-06:00" "-XMP-PHOTOSHOP:DATECREATED=2010:01:01 00:00:00-06:00" "-XMP-XMP:MODIFYDATE=2010:01:01 00:00:00-06:00" "-XMP:DATE=2010:01:01 00:00:00-06:00" "-EXIF:DATETIMEORIGINAL=2010:01:01 00:00:00-06:00" "-EXIF:CREATEDATE=2010:01:01 00:00:00-06:00" "-EXIF:MODIFYDATE=2010:01:01 00:00:00-06:00" "-MAKERNOTES:TIMESTAMP=2010:01:01 00:00:00-06:00" "-GPS:GPSDATESTAMP=2010:01:01 00:00:00-06:00" "-GPS:GPSTIMESTAMP=2010:01:01 00:00:00-06:00" "-XMP-EXIF:GPSDATETIME=2010:01:01 00:00:00-06:00" "C:\...\pictures\2010"

Then adding -wm w for some tags:

exiftool -XMP:CREATEDATE="2010:01:01 00:00:00-06:00" "-XMP-PHOTOSHOP:DATECREATED=2010:01:01 00:00:00-06:00" "-XMP-XMP:MODIFYDATE=2010:01:01 00:00:00-06:00" "-XMP:DATE=2010:01:01 00:00:00-06:00" "-EXIF:DATETIMEORIGINAL=2010:01:01 00:00:00-06:00" "-EXIF:CREATEDATE=2010:01:01 00:00:00-06:00" "-EXIF:MODIFYDATE=2010:01:01 00:00:00-06:00" "-MAKERNOTES:TIMESTAMP=2010:01:01 00:00:00-06:00" "-GPS:GPSDATESTAMP=2010:01:01 00:00:00-06:00" "-GPS:GPSTIMESTAMP=2010:01:01 00:00:00-06:00" "-XMP-EXIF:GPSDATETIME=2010:01:01 00:00:00-06:00" -execute -wm w "-IPTC:DIGITALCREATIONDATE=2010:01:01 00:00:00-06:00" "-IPTC:DIGITALCREATIONTIME=2010:01:01 00:00:00-06:00" "-IPTC:DATECREATED=2010:01:01 00:00:00-06:00" "-IPTC:TIMECREATED=2010:01:01 00:00:00-06:00" "-XMP-EXIF:DATETIMEDIGITIZED=2010:01:01 00:00:00-06:00" "-XMP-EXIF:DATETIMEORIGINAL=2010:01:01 00:00:00-06:00" "-XMP-EXIF:GPSDATETIME=2010:01:01 00:00:00-06:00" "-XMP-MICROSOFT:DATEACQUIRED=2010:01:01 00:00:00-06:00" -common_args -overwrite_original "C:\...\pictures\2010"

or better yet, with an argfile:

exiftool -@ my.args -common_args -overwrite_original "C:\...\pictures\2010"

where my.args is:

Code: [Select]
-XMP:CREATEDATE=2010:01:01 00:00:00-06:00
-XMP-PHOTOSHOP:DATECREATED=2010:01:01 00:00:00-06:00
-XMP-XMP:MODIFYDATE=2010:01:01 00:00:00-06:00
-XMP:DATE=2010:01:01 00:00:00-06:00
-EXIF:DATETIMEORIGINAL=2010:01:01 00:00:00-06:00
-EXIF:CREATEDATE=2010:01:01 00:00:00-06:00
-EXIF:MODIFYDATE=2010:01:01 00:00:00-06:00
-MAKERNOTES:TIMESTAMP=2010:01:01 00:00:00-06:00
-GPS:GPSDATESTAMP=2010:01:01 00:00:00-06:00
-GPS:GPSTIMESTAMP=2010:01:01 00:00:00-06:00
-XMP-EXIF:GPSDATETIME=2010:01:01 00:00:00-06:00
-execute
-wm
w
-IPTC:DIGITALCREATIONDATE=2010:01:01 00:00:00-06:00
-IPTC:DIGITALCREATIONTIME=2010:01:01 00:00:00-06:00
-IPTC:DATECREATED=2010:01:01 00:00:00-06:00
-IPTC:TIMECREATED=2010:01:01 00:00:00-06:00
-XMP-EXIF:DATETIMEDIGITIZED=2010:01:01 00:00:00-06:00
-XMP-EXIF:DATETIMEORIGINAL=2010:01:01 00:00:00-06:00
-XMP-EXIF:GPSDATETIME=2010:01:01 00:00:00-06:00
-XMP-MICROSOFT:DATEACQUIRED=2010:01:01 00:00:00-06:00

... of course, you need to decide which tags you want to create, and which you don't.

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

47u2caryj

  • Jr. Member
  • **
  • Posts: 10
Re: Move to Directory
« Reply #12 on: April 18, 2016, 02:17:54 PM »
Looking for a second set of eyes to review.
I tried to simplify my Windows Batch File to the following.

exiftool -ext jpg -ext tiff -m -P -progress -if "$datetimeoriginal gt '2009:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\2010s\$datetimeoriginal" -execute -if "$datetimeoriginal gt '1999:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\2000s\$datetimeoriginal" -execute -if "$datetimeoriginal gt '1989:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1990s\$datetimeoriginal" -execute -if "$datetimeoriginal gt '1979:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1980s\$datetimeoriginal" -execute -if "$datetimeoriginal gt '1969:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1970s\$datetimeoriginal" -execute -if "$datetimeoriginal gt '1959:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1960s\$datetimeoriginal" -execute -if "$datetimeoriginal gt '1949:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1950s\$datetimeoriginal" -execute -if "$datetimeoriginal gt '1939:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1940s\$datetimeoriginal" -execute -if "$datetimeoriginal gt '1929:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1930s\$datetimeoriginal" -execute -if "$datetimeoriginal gt '1919:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1920s\$datetimeoriginal" -execute -if "$datetimeoriginal gt '1909:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1910s\$datetimeoriginal" -execute -if "$datetimeoriginal gt '1899:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1900s\$datetimeoriginal" -execute "-directory<D:\OneDrive\Pictures\Sorted\0000s\$datetimeoriginal" -common_args -d %%Y/%%m-%%b  "D:\OneDrive\Pictures\Camera Roll"

I can include examples if needed but I'm getting a strange behavior where a file will be assigned ...\2000s\2011\... or ...\2000s\2012\... ... or  ...\1990s\2004\... so the logic is finding the datetimeoriginal to file it in the correct year\month subdirectory but the logic is failing with assigning to the correct decade.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 14405
    • ExifTool Home Page
Re: Move to Directory
« Reply #13 on: April 18, 2016, 03:18:30 PM »
I should have picked up on this before.  Try comparing with $datetimeoriginal# instead of $datetimeoriginal.  Without specifying that you want the numerical value, you are comparing with the reformatted date/time value (ah-la the -d option), but your comparison strings aren't formatted this way.

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

47u2caryj

  • Jr. Member
  • **
  • Posts: 10
Re: Move to Directory
« Reply #14 on: April 19, 2016, 03:31:17 PM »
Hi Phil,
Thanks for your help.
I updated the script to the following to no avail.
Any additional assistance would be appreciated.

exiftool -ext jpg -ext tiff -m -P -progress -if "$datetimeoriginal# gt '2009:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\2010s\$datetimeoriginal" -execute -if "$datetimeoriginal# gt '1999:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\2000s\$datetimeoriginal" -execute -if "$datetimeoriginal# gt '1989:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1990s\$datetimeoriginal" -execute -if "$datetimeoriginal# gt '1979:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1980s\$datetimeoriginal" -execute -if "$datetimeoriginal# gt '1969:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1970s\$datetimeoriginal" -execute -if "$datetimeoriginal# gt '1959:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1960s\$datetimeoriginal" -execute -if "$datetimeoriginal# gt '1949:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1950s\$datetimeoriginal" -execute -if "$datetimeoriginal# gt '1939:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1940s\$datetimeoriginal" -execute -if "$datetimeoriginal# gt '1929:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1930s\$datetimeoriginal" -execute -if "$datetimeoriginal# gt '1919:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1920s\$datetimeoriginal" -execute -if "$datetimeoriginal# gt '1909:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1910s\$datetimeoriginal" -execute -if "$datetimeoriginal# gt '1899:12:31'" "-directory<D:\OneDrive\Pictures\Sorted\1900s\$datetimeoriginal" -execute "-directory<D:\OneDrive\Pictures\Sorted\0000s\$datetimeoriginal" -common_args -d %%Y/%%m-%%b  "D:\OneDrive\Pictures\Camera Roll"