ExifTool Forum

ExifTool => Newbies => Topic started by: marto2013 on May 24, 2020, 12:57:54 AM

Title: Warning: garbage at end of string in strptime
Post by: marto2013 on May 24, 2020, 12:57:54 AM
Hi :),
How can I set filemodifydate from filename that has different symbols with different length? I will give some filename examples:
"2018-11-06___Изоставеният град.docx"
"2019-01-25___Изпитът.docx"

What I tried:

PS D:\Documents\Personal\Dreams> exiftool -d "%Y-%m-%d" "-filemodifydate<filename" "2017-07-22___Сънищата-с-Кучетата.docx"
Warning: garbage at end of string in strptime: ___Сънищата-с-Кучетата.docx in File:FileModifyDate (PrintConvInv) - 2017-07-22___Сънищата-с-Кучетата.docx
Warning: No writable tags set from 2017-07-22___Сънищата-с-Кучетата.docx
    0 image files updated
    1 image files unchanged


I tried also exiftool -d "%Y-%m-%d___Сънищата-с-Кучетата.docx" "-filemodifydate<filename" "2017-07-22___Сънищата-с-Кучетата.docx" and it works, but I need batch command.

Thanks!
Title: Re: Warning: garbage at end of string in strptime
Post by: StarGeek on May 24, 2020, 01:15:47 AM
The problem is that there aren't enough digits.  The FileModifyDate needs date and time data.  Additionally, the -d isn't needed.

Try something like
exiftool "-filemodifydate<$filename 00:00:00" /path/to/files/
Title: Re: Warning: garbage at end of string in strptime
Post by: marto2013 on May 24, 2020, 07:55:34 AM
Thank you, but It did not work out  :'(

PS D:\Documents\Personal\Dreams> exiftool "-filemodifydate<$filename 00:00:00" "2017-07-22___Сънищата-с-Кучетата.docx"
Warning: No writable tags set from 2017-07-22___Сънищата-с-Кучетата.docx
Warning: Invalid tag name '00:00:00' - 2017-07-22___Сънищата-с-Кучетата.docx
    0 image files updated
    1 image files unchanged


EDIT:
I found a command that worked :D

exiftool '-filemodifydate<${filename;/(\d{4}\D?\d{2}\D?\d{2})/;$_=$1} 00:00:00' "*"

(I get it from there: https://exiftool.org/forum/index.php?topic=10473.msg55290#msg55290)
Title: Re: Warning: garbage at end of string in strptime
Post by: StarGeek on May 24, 2020, 12:00:15 PM
That would have been my next suggestion :)

But it's strange that my command didn't work for you.  I changed a file to have the same name as yours and ran my command and it worked for me.  I did have to run it on the directory and not the file name because I couldn't get either Powershell or CMD to display Cyrillic characters.
Title: Re: Warning: garbage at end of string in strptime
Post by: marto2013 on May 24, 2020, 12:53:20 PM
I tried your command with CMD and it worked.. after that I tried it again with PowerShell and it did not work out. That's strange...

With CMD: https://i.imgur.com/yggr5aS.png
With PowerShell: https://i.imgur.com/23zJHJP.png
Title: Re: Warning: garbage at end of string in strptime
Post by: StarGeek on May 24, 2020, 01:00:24 PM
I believe that PowerShell works more like Linux bash/Mac Terminal with regards to quotes.  If you change the double quotes to single quotes, I think it would work.

What code page are you using?  Type chcp to see what it is.
Title: Re: Warning: garbage at end of string in strptime
Post by: marto2013 on May 24, 2020, 01:12:12 PM
QuoteWhat code page are you using? Type chcp to see what it is.
My code page is 65001.

QuoteI believe that PowerShell works more like Linux bash/Mac Terminal with regards to quotes. If you change the double quotes to single quotes, I think it would work.
Thank you very much! I didn't know that. With single quotes, it works ;D
Title: Re: Warning: garbage at end of string in strptime
Post by: StarGeek on May 24, 2020, 01:38:15 PM
Quote from: marto2013 on May 24, 2020, 01:12:12 PM
My code page is 65001.

Heh, this is the reason I get so annoyed with Windows.  I also set my code page to 65001 and I still couldn't get Cyrillic characters to display properly.
Title: Re: Warning: garbage at end of string in strptime
Post by: Phil Harvey on May 25, 2020, 09:13:58 AM
As well as setting a code page that supports the characters, the font you are using must also support these characters.

- Phil
Title: Re: Warning: garbage at end of string in strptime
Post by: StarGeek on May 25, 2020, 12:04:59 PM
Yeah, I've tried both Lucida Console and Courier New, both support Cyrillic when I use them in other programs.  I just can't seem to get it to work in PS or the new Windows Terminal.  They display correctly in CMD, though. 

My system is weird :P