ExifTool Forum

ExifTool => Newbies => Topic started by: ideal on April 26, 2018, 08:01:04 AM

Title: adding a copy number with leading '-' if the file already exists (%-c)
Post by: ideal on April 26, 2018, 08:01:04 AM
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
Title: Re: adding a copy number with leading '-' if the file already exists (%-c)
Post by: StarGeek on April 26, 2018, 11:05:37 AM
%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 (https://exiftool.org/exiftool_pod.html#RENAMING-EXAMPLES).

exiftool -d "%%y-%%m-%%d--%%H%%M%%S%%%%-c.%%%%e" "-filename<createdate" -k %*
Title: Re: adding a copy number with leading '-' if the file already exists (%-c)
Post by: ideal on April 26, 2018, 02:09:00 PM
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!
Title: Re: adding a copy number with leading '-' if the file already exists (%-c)
Post by: StarGeek on April 26, 2018, 04:10:10 PM
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 (https://ss64.com/nt/pause.html).  Just put that as the last line of your bat file.
Title: Re: adding a copy number with leading '-' if the file already exists (%-c)
Post by: ideal on May 14, 2018, 02:12:15 PM
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
Title: Re: adding a copy number with leading '-' if the file already exists (%-c)
Post by: StarGeek on May 14, 2018, 04:41:01 PM
Use double quotes on Windows to prevent file redirection

exiftool "-Directory<createdate" -d %%%%Y/%%%%%m/%%%%%d dir  -k %*
Title: Re: adding a copy number with leading '-' if the file already exists (%-c)
Post by: ideal on May 15, 2018, 04:36:12 AM
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

Title: Re: adding a copy number with leading '-' if the file already exists (%-c)
Post by: Phil Harvey on May 15, 2018, 07:11:07 AM
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
Title: Re: adding a copy number with leading '-' if the file already exists (%-c)
Post by: ideal on May 15, 2018, 08:56:36 AM
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!
Title: Re: adding a copy number with leading '-' if the file already exists (%-c)
Post by: Phil Harvey on May 15, 2018, 09:22:42 AM
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