Thread

Posted on Mon Dec 17 20:54:14 2007 by bv
How to rename a file and move it to a different drive and directory

How to rename a file and move it to a different drive and directory based on the -DateTimeOriginal tag when both operations uses a different -D format.

I have created the following @ ArgFile example. it contains the details of what I am trying to do and why it does not work.

If anyone knows how I can do this successfully (does not have to be the same approach), I am all ears.

# EXIFTool ArgFile (windows standalone version 7.06 # Uasge: # F:\Photos\1980_01_01>exiftool -@ bv_FIXALL.arg -common_args img_0008.jpg # # Trying to perform the following tasks: # 1 Set the IPTC DateCreated: 2007:09:05 # Makes backup of original file # 2 Sets the following # IPTC CopyrightNotice: (c) 2007 by Brooks Vaughn. All rights reserved. # XMP-xmpRights Owner: Brooks Vaughn # IFD0 Artist: Brooks Vaughn # File Comment: email BrooksVaughn@xxx.xxx for information, usage, and licensing. All # 3 Rename File in the following format: # 2007-0905-163014_100-0008.txt, 2007-0905-163014_100-0008-01.txt, # 2007-0905-163014_100-0008-02.txt # 4 Moving the newly renamed file # - Create a directory (Q:\Photos\2007_09_05) # - Move the newly renamed file (2007-0905-163014_100-0008.txt) to Q:\Photos\2007_09_05 # where folder "2007_09_05" is created from the DateTimeOriginal TAG # # ISSUES # # 1 I had to break up into different -EXECUTE sections because each uses a # different -D (date format) in it's processing. # 2 I had to envolk using -common_arg otion as each section could not see the # filename passed to it after the first section executed. # 3 Unable to get section #4 working within the executation of this file # because after the filename is changed in Section #3, it is still looking # for the original filename. # # NOTES # # 1 There is a case change with the original filename "IMG_0008.JPG" # was backed up and renamed to "img_0008.jpg_original" # # BEGIN Processing # # 1 Set the IPTC DateCreated: 2007:09:05 # Makes Backup of Original file # WORKING -P -d "%Y:%m:%d"" -DateTimeOriginal>DateCreated -execute # # 2 Sets More Data # WORKING -P -d %Y -CopyrightNotice<(c) ${DateTimeOriginal} by Brooks Vaughn. All rights reserved. -Owner=Brooks Vaughn -Artist=Brooks Vaughn -Comment=email BrooksVaughn@hotmail.com for information, usage, and licensing. All unauthorized usa +ge is strictly forbidden. -execute # # 3 Rename File # WORKING -P -d %Y-%m%d-%H%M%S -FileName<${DateTimeOriginal}_${filenumber}%.8f%-2c.%ue -execute # # 4 Move the renamed file to New Direct, create if not exists # # Works if standalone and envolked using the new file name # UNABLE to get working. I suspect that it does not know what the # new filename is so it fails to find a file to move -d %Y_%m_%d -Directory<Q:\Photos\${DateTimeOriginal} # # Then End #
Direct Responses: 6700 | Write a response
Posted on Mon Dec 17 21:44:49 2007 by exiftool in response to 6699
Re: How to rename a file and move it to a different drive and directory
You can solve your problems with 3 and 4 by setting the directory and filename together:

-d Q:/Photos/%Y_%m_%d/%Y-%m%d-%H%M%S -filename<${DateTimeOriginal}_${filenumber}%.8f%-2c.%ue

(note, I haven't tested this so there may be typos)

The alternative is to create a couple of user-defined tags to help you out: One (DateTime2) to give an unformatted date for copying to IPTC:DateCreated, and the other (Year) to extract the year from DateTimeOriginal for the Copyright tag. With these, you could get away with a single -d format, and everything could be accomplished in a single step.

%Image::ExifTool::UserDefined = ( 'Image::ExifTool::Composite' => { DateTime2 => { Require => 'DateTimeOriginal', ValueConv => '$val', }, Year => { Require => 'DateTimeOriginal', ValueConv => '$val=~s/:.*//; $val', }, }, );

- Phil
Direct Responses: 6701 | 6708 | Write a response
Posted on Mon Dec 17 21:47:57 2007 by exiftool in response to 6700
Re: How to rename a file and move it to a different drive and directory
Sorry. I said "The alternative" above, but this was an editing artifact. In fact, the user-defined tags must be used in combination with setting the directory/filename together to accomplish this in a single step.

- Phil
Direct Responses: 6702 | Write a response
Posted on Mon Dec 17 22:40:04 2007 by bv in response to 6701
Re: How to rename a file and move it to a different drive and directory
Philip,

It works great. You are pure Genius. I would have never thought of specifiying the -d Q:/Photos/%Y_%m_%d/%Y-%m%d-%H%M%S in format in this way. I only downladed Exiftools yesterday and have only spent 16+ hours trying to figure out the syntax and make it accomplish my reorganization of 63,000+ files.

Is the user-defined tags example you provided worth trying?

My next step is to try testing using the -r and to also process not only the JPG file but also the CR2 files.

Did you have a way to combine steps 1 and 2?

Thanks again,

- Brooks

Direct Responses: 6705 | Write a response
Posted on Tue Dec 18 01:42:48 2007 by exiftool in response to 6702
Re: How to rename a file and move it to a different drive and directory
You ask if the user-defined tags are worth trying. If you can reduce your processing from 3 to 1 steps, then it will go three times faster. And with 63k files to process, this could make it worth while.

With the user-defined tags in place, all steps are combined together with the following argfile:

# EXIFTool ArgFile (windows standalone version 7.06 # Uasge: # F:\Photos\1980_01_01>exiftool -@ bv_FIXALL.arg -common_args img_0008.jpg # -P -DateTime2>IPTC:DateCreated -CopyrightNotice<(c) ${Year} by Brooks Vaughn. All rights reserved. -Owner=Brooks Vaughn -Artist=Brooks Vaughn -Comment=email BrooksVaughn@hotmail.com for information, usage, and licensing. All unauthorized usa +ge is strictly forbidden. -d Q:/Photos/%Y_%m_%d/%Y-%m%d-%H%M%S -filename<${DateTimeOriginal}_${filenumber}%.8f%-2c.%ue

- Phil
Direct Responses: 6707 | Write a response
Posted on Tue Dec 18 02:01:55 2007 by exiftool in response to 6705
Re: How to rename a file and move it to a different drive and directory
I wasn't paying attention when I cut 'n pasted your command line comment, but of course you no longer need to use the -common_args argument.

- Phil
Write a response
Posted on Tue Dec 18 02:26:43 2007 by bv in response to 6700
Re: How to rename a file and move it to a different drive and directory

Hi Phil,

Do I put user-defined tags (as you wrote in the previos messages) at the bottom of the .exiftool_config file or put just the definations "DateTime2" and "Year" into the existing section?

Brooks

Direct Responses: 6710 | Write a response
Posted on Tue Dec 18 03:12:47 2007 by exiftool in response to 6708
Re: How to rename a file and move it to a different drive and directory
That was a complete config file I posted. The rest of the sample ExifTool_config defines a bunch of other tags as examples, and you don't need these.

- Phil
Write a response