Moving and renaming in Windows

Started by amuelder, February 08, 2016, 04:25:56 PM

Previous topic - Next topic

amuelder

Hello,

I shoot JPG and RAW on my Fuji. I'm on Windows 7. My goal is to use ExifTool to copy all images into this structure:

c:\users\andy\pics\YYYY\mm-dd\yymmdd_image_###_FilmMode.ext
In other words: ..\pics\2016\01-29\160129_image_001_Astia.jpg
### being a consecutive number

Preferrably even with sub folder after the date for JPG and for RAF files.

1.) Create subfolder bases on Date
I got this one to work:
exiftool "-Directory<DateTimeOriginal" -d %%Y/%%m-%%d/ .


But not this one
exiftool "-Directory<DateTimeOriginal" -d %%Y/%%m-%%d/%%e .
or exiftool "-Directory<DateTimeOriginal" -d %%Y/%%m-%%d/%%e/ .

Why not?

2.) I tried to rename the files, completely without success.
Can someone please point me in the right direction or even post a solution to this?
For example:
exiftool -r -d %%Y%%m_image_%%1.3C.%%%e "-filename<CreateDate" .
Renames my file to literaly %Y%m_image_001.JPG.
No matter how many %-signs I add infront of the Year and the Month, it just won't show the Year or the Month.

On top of this: I got the FilmMode Tag from another post here. Thanks again! But unfortunately I don't manage to include this in the code above.
exiftool -r -d %%Y%%m_image_%%1.3C_${FilmMode;}.%%%e "-filename<CreateDate" .
Please help.

Sorry if I missed something.

Thanks and regards
Andy

StarGeek

Is this in a batch file or on the command line?

If on the command line, then you should only be using single percent signs in date formatting codes except in the case of %c, %d, %f and %e.  When used in a date formatting code, as with the -d option as you are doing, the percent sign in %c, %d, %f and %e needs to be doubled.

If used in a batch file, then all percent signs need to be doubled.

For example, your second to last command would be
exiftool -r -d %Y%m_image_%%1.3C.%%e "-filename<CreateDate" .
on the command line or
exiftool -r -d %%Y%%m_image_%%%%1.3C.%%%%e "-filename<CreateDate" .
in a batch file.

Take a look at renaming examples and FileName and Directory tags for some more details.

Your last command, I don't think you can add a tag to a -d date format string.  You have to format that part in the tag assignment part
exiftool -r -d "%Y%m_image_%%1.3C" "-filename<${CreateDate}_${FilmMode;}.%e" .

Notice that in this example, there is only one percent sign in front of the e.  That's because it is not in the date formatting string.  And of course, double all percent signs if using a batch file.

"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

amuelder

#2
Hello Stargeek,

Thank you, again. I'm running this in a batch file.
I read the examples but I didn't understand why some need only a single % and other need double %. I do now.
I do a second pass for the renaming with the FilmMode after the first pass.

exiftool -r -d C:\Users\Andy\pics\private/%%Y/%%m-%%d/%%%%e/%%y%%m%%d_image_%%%%1.3C.%%%%e "-filename<CreateDate" .
exiftool -r "-filename<%%f_${FilmMode;}.%%e" C:\Users\Andy\pics\private/


This works fine now. Thank you.
Andy

StarGeek

"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

amuelder

May I ask for additional assistance?

Fuji seems to have quite extensive names for some of their film modes, e.g. "F1b/Studio Portrait Smooth Skin Tone (Astia)".
Whereas I would prefer to just rename the file to
160207_image_354_Astia.JPG
instead of
160207_image_354_F1bStudio Portrait Smooth Skin Tone (Astia).JPG

I'm trying to fix this with the If condition. Where is my mistake?
exiftool -k -if "$Filmmode = 'F1b/Studio Portrait Smooth Skin Tone (Astia)'" "-filename<%%f_Astia.%%e" -ext JPG .

StarGeek

Since ExifTool was created using perl, various bits of how it works are basically perl code.  In this case, the equal sign is the assignment operator and won't work with your if condition.

What you want to use is the string equals operator, eq.  So try this command:
exiftool -k -if "$Filmmode eq 'F1b/Studio Portrait Smooth Skin Tone (Astia)'" "-filename<%%f_Astia.%%e" -ext JPG .
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

amuelder

Sorry, that doesn't seem to work either.
I'm running this in a batch file and get the following response:

Warning: Invalid tag name '%f_astia.%e' - ./test.JPG

What I don't understand, because in another thread I learned that this command successfully renames the files:

exiftool "-filename<%%f_${FilmMode;}.%%e" a.jpg

There's only a slight deviation ${FilmMode;} against Astia

Phil Harvey

StarGeek was very close, but made an easy mistake (using "<" instead of "=" when simply assigning a value).  Try this:

exiftool -k -if "$Filmmode eq 'F1b/Studio Portrait Smooth Skin Tone (Astia)'" "-filename=%%f_Astia.%%e" -ext JPG .

The problem is that "<" expects either a tag name, or an expression containing tag names preceded by "$" characters.  Since there are no "$" characters, it interprets %f_Astia.%e as a tag name.

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

amuelder


amuelder

Another problem. More a logical one than a programming issue.

My intention is to use ExifTool to
1. Copy all files from the SD card onto the local harddrive
2. Rename the files and place them in a certrain folder structure.
3. Amend the FilmMode to Filename

In a batch file I use one ExifTool command to accomplish step 1 and 2. Then I use a second command to accomplish step 3. Once those files are renamed, if I use this batch file again, the second command will rename all existing files double, triple, ..

Command 1:
exiftool -k -r -d "c:\Users\andym\Pictures\temp_raw\%%Y/%%m-%%d/%%%%e/%%y%%m%%d_image_%%%%1.3C.%%%%e" "-filename<CreateDate" H:\DCIM

Command 2:
exiftool -if "$Filmmode eq 'F0/Standard (Provia)'" "-filename=%%f_Provia.%%e" -ext JPG DIR

What is the best logic to avoid this?
Option A) Insert a third command line to move all files from temporary folder to final folder.
The downside is double file movement.

Option B) Somehow get ExifTool to work only on unprocesed files.
But how?

What is your opinion?

Phil Harvey

You could do this in a single command:

exiftool -k -r -d "c:/Users/andym/Pictures/temp_raw/%%Y/%%m-%%d/%%%%e/%%y%%m%%d_image_%%%%1.3C" "-filename<${CreateDate}.%%e" "-filename<${CreateDate}${filmmode;$_ = /Provia/ ? '_Provia' : ''}.%%e" H:\DCIM

The first filename argument is necessary for the case where FilmMode doesn't exist.

Note that this command should move the images from the SD card, not just copy them.  You should add -o dummy/ to copy the files instead.  It is best not to write to the SD card in case it has some problems.  After the images are copied and you have suitable backups, then format the SD card to remove the images.  Just deleting images from an SD card is dangerous.

Also note that this command won't copy files that aren't writable by ExifTool (ie. AVI files).  So you may want to add explicit -ext options for all of the files you want to copy.  Also, this won't copy files that don't have a CreateDate tag.

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

amuelder

Phil,

thanks for your explanation. I will add the -o dummy/ argument to copy the file. I don't do movies. "Stills-only" kinda guy. Formatting is also my preferred choice.

However, regarding the one-command solution, I'm not sure this will work.

Fuji offeres several FilmModes. I use around 7-8 of them. Because some of them have rather long descriptions in the tag, I use IF-command to amend the filename by a shorter version.

exiftool -if "$Filmmode eq 'F0/Standard (Provia)'" "-filename=%%f_Provia.%%e" -ext JPG .
exiftool -if "$Filmmode eq 'F2/Fujichrome (Velvia)'" "-filename=%%f_Velvia.%%e" -ext JPG .
exiftool -if "$Filmmode eq 'F1b/Studio Portrait Smooth Skin Tone (Astia)'" "-filename=%%f_Astia.%%e" -ext JPG .
exiftool -if "$Filmmode eq 'Classic Chrome'" "-filename=%%f_ClassicChrome.%%e" -ext JPG .
exiftool -if "$Filmmode eq 'Pro Neg. Hi'" "-filename=%%f_ProNegHi.%%e" -ext JPG .
exiftool -if "$Filmmode eq 'Pro Neg. Std'" "-filename=%%f_ProNegStd.%%e" -ext JPG .
exiftool -if "$Saturation eq 'None (B&W)'" "-filename=%%f_BW.%%e" -ext JPG .
exiftool -if "$Saturation eq 'B&W Yellow Filter'" "-filename=%%f_BW-Yellow.%%e" -ext JPG .
exiftool -if "$Saturation eq 'B&W Red Filter'" "-filename=%%f_BW-Red.%%e" -ext JPG .
exiftool -if "$Saturation eq 'B&W Green Filter'" "-filename=%%f_BW-Green.%%e" -ext JPG .



Would you put all this in one single command?

Phil Harvey

#12
This type of complex logic is better suited to a user-defined tag.  This may be done with the attached config file and the following command:

exiftool -config MyName.config -k -r -d "c:/Users/andym/Pictures/temp_raw/%%Y/%%m-%%d/%%%%e/%%y%%m%%d_image_%%%%1.3C" "-filename<${MyName}.%%e" -ext jpg H:\DCIM

This will copy and rename the JPG files.  It seems you may want to copy the others too (but not rename them in the same way?):

exiftool -k -r -d "c:\Users\andym\Pictures\temp_raw\%%Y/%%m-%%d/%%%%e/%%y%%m%%d_image_%%%%1.3C.%%%%e" "-filename<CreateDate" --ext jpg H:\DCIM

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

amuelder

Thank you. I will give this a try later on.

The Fuji FilmMode is an in-camera preset regarding color and contrast rendition.

The Raw files are equally imported, but I won't add the FilmMode suffix to the filenames since it's raw. Finally I place each type in a different sub-folder: /%%Y/%%m-%%d/%%%%e/ But only JPGs should show the FilmMode.

After years of working on only CR2 files, I just started with Fuji this year. I like their JPG rendering. By having the FilmMode mentioned in the name I want to learn which type works in which way.

StarGeek

Quote from: Phil Harvey on February 11, 2016, 07:23:43 AM
StarGeek was very close, but made an easy mistake (using "<" instead of "=" when simply assigning a value).

And it's a mistake I will probably keep making unless I actually double check commands to make sure they work.  I KNOW the difference between the two, but still mess them up when I'm not paying full attention.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype