Main Menu

Move to Directory

Started by 47u2caryj, March 20, 2016, 10:43:56 PM

Previous topic - Next topic

47u2caryj

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

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.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

47u2caryj

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

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

In Windows batch files, you need to double all your % characters :)
Hayo Baan – Photography
Web: www.hayobaan.nl

47u2caryj

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

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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

47u2caryj

Thank you this worked.
I will be back with further questions.
I appreciate the automation the tool provides.

47u2caryj

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

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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

47u2caryj

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

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:

-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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

47u2caryj

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

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/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

47u2caryj

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"