adding a copy number with leading '-' if the file already exists (%-c)

Started by ideal, April 26, 2018, 08:01:04 AM

Previous topic - Next topic

ideal

Hello  Hope for help
I´m trying to add a copy number with leading '-' if the file already exists  and cannot get it to work in my Batch..(using double percent right?)
exiftool -d "%%y-%%m-%%d--%%H%%M%%S%%-c.%%%%e" "-filename<createdate" -k %* doesnt work
rem exiftool -d "%%y-%%m-%%d--%%H%%M%%S.%%%%e" "-filename<createdate" -k %*  works but i get files that are not renamed because the filname already  exists.

Where am i ging wrong?
Version 10.9.40 on win 10 Defender off

Thanks

StarGeek

%f, %e, %d, and %c all need to have double percent signs when used in a date format string, which need to be doubled again when used in a Windows batch file.  See the first paragraph of Renaming Examples.

exiftool -d "%%y-%%m-%%d--%%H%%M%%S%%%%-c.%%%%e" "-filename<createdate" -k %*
"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

ideal

Great! so many thanks! it works on the jpg and on the iphone Movs as well! (after i left the [/tt away. is it another tip ? i searched the expression in the documentation but could not find it..

Im a bit  disencanted after i tried so much gettin the first thing going and then i missed such a stupid detail... must be my english a bit.. so i hope you don´t mind me beein a bit lazy...and help me once more..

now ideally im tryin to combine it with someting like exiftool '-Directory<createdate' -d %%%%Y/%%%%%m/%%%%%d dir  -k%*    but again i cant even gert it going it doesnt even keep the window open..  or do i just need run somting like that after ?

Thank you soo much again!

StarGeek

Quote from: ideal on April 26, 2018, 02:09:00 PM
(after i left the [/tt away. is it another tip ? i searched the expression in the documentation but could not find it..

Nope, not a exiftool tip.  It's formatting tip for the board.  Read the text directly below the text box when you post something.

Quotenow ideally im tryin to combine it with someting like exiftool '-Directory<createdate' -d %%%%Y/%%%%%m/%%%%%d dir  -k%*    but again i cant even gert it going it doesnt even keep the window open..  or do i just need run somting like that after ?

The example you posted needs a space between the -k and the %*.  Otherwise it should work.  Additionally, there's always the windows Pause command.  Just put that as the last line of your bat 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

ideal

so i put exiftool '-Directory<createdate' -d %%%%Y/%%%%%m/%%%%%d dir  -k %*
pause

and i get
C:\test volker bild>exiftool '-Directory -d %%Y/%%%%d dir  -k "C:\test volker bild\tosort" 0<createdate'
Das System kann die angegebene Datei nicht finden. (system cannot find the file pointed out)

C:\test volker bild>pause
Drücken Sie eine beliebige Taste . . .
when i pull C:\test volker bild\tosort folder onto the batch...
please help

StarGeek

Use double quotes on Windows to prevent file redirection

exiftool "-Directory<createdate" -d %%%%Y/%%%%%m/%%%%%d dir  -k %*
"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

ideal

Great, never thought itll be that, tried forever; it only kind of works now and tries the mov too!,but now i get´this error4 all files:
Error creating directory %Y/170:
Warning: New file name not allowed in Windows (contains ':') - C:/test volker bild/tosort/IMG_0576.JPG
Error creating directory %Y/171:
Warning: New file name not allowed in Windows (contains ':') - C:/test volker bild/tosort/IMG_0594.JPG
Error creating directory %Y/172:

i assumed its the createdate containing ":", but i need createdate since the mov files dont contain DateTimeOriginal and i get a" no writable tags set"error and on the jpegs it complains about ":" as well so it gotte be somthing else...


C:\test volker bild\tosort>exiftool -s -time:all IMG_0001.jpg
FileModifyDate                  : 2018:04:23 15:46:52+02:00
FileAccessDate                  : 2018:05:14 19:55:05+02:00
FileCreateDate                  : 2018:05:14 19:55:05+02:00
ModifyDate                      : 2015:01:20 12:38:35
DateTimeOriginal                : 2015:01:20 12:38:35
CreateDate                      : 2015:01:20 12:38:35
SubSecTimeOriginal              : 348
SubSecTimeDigitized             : 348
SubSecCreateDate                : 2015:01:20 12:38:35.348
SubSecDateTimeOriginal          : 2015:01:20 12:38:35.348


C:\test volker bild\tosort>exiftool -s -time:all _a001.mov
FileModifyDate                  : 2018:04:23 15:47:30+02:00
FileAccessDate                  : 2018:05:14 19:55:13+02:00
FileCreateDate                  : 2018:05:14 19:55:13+02:00
CreateDate                      : 2015:02:17 15:08:31
ModifyDate                      : 2015:02:17 15:10:18
TrackCreateDate                 : 2015:02:17 15:08:31
TrackModifyDate                 : 2015:02:17 15:10:18
MediaCreateDate                 : 2015:02:17 15:08:31
MediaModifyDate                 : 2015:02:17 15:10:18
CreationDate-deu-DE             : 2015:02:17 16:08:31+01:00
ContentCreateDate-deu           : 2015:02:17 16:08:31+01:00
CreationDate                    : 2015:02:17 16:08:31+01:00
ContentCreateDate               : 2015:02:17 16:08:31+01:00


Phil Harvey

You've got too many %'s.  In a batch file, you should have 2 "%" characters for date/time format codes like StarGeek said in his first post:

exiftool "-Directory<createdate" -d %%Y/%%m/%%d -k %*

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

ideal

Tanks runss great... guess i missunderstood the post quote "%f, %e, %d, and %c all need to have double percent signs when used in a date format string, which need to be doubled again when used in a Windows batch file."


Graeat forum! Great Tool! really helpfull THANXXXXX!

Phil Harvey

The %f, %e, %d and %c are the file name, extension, directory and copy number of the file.  And yes, these would need 4 "%" characters for these in the -d argument in a .bat file, but you aren't using any of these.

For example.  In the -d argument in a .bat file:

%%%%d = directory name

%%d = day of month

Confusing, I know.  But it makes sense if you understand how the date/time values and file names are parsed.

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