Author Topic: Warning: garbage at end of string in strptime  (Read 212 times)

marto2013

  • Newbie
  • *
  • Posts: 4
Warning: garbage at end of string in strptime
« 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:
Code: [Select]
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
Code: [Select]
exiftool -d "%Y-%m-%d___Сънищата-с-Кучетата.docx" "-filemodifydate<filename" "2017-07-22___Сънищата-с-Кучетата.docx" and it works, but I need batch command.

Thanks!

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3684
Re: Warning: garbage at end of string in strptime
« Reply #1 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/
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

marto2013

  • Newbie
  • *
  • Posts: 4
Re: Warning: garbage at end of string in strptime
« Reply #2 on: May 24, 2020, 07:55:34 AM »
Thank you, but It did not work out  :'(
Code: [Select]
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

Code: [Select]
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)

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3684
Re: Warning: garbage at end of string in strptime
« Reply #3 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.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

marto2013

  • Newbie
  • *
  • Posts: 4
Re: Warning: garbage at end of string in strptime
« Reply #4 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

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3684
Re: Warning: garbage at end of string in strptime
« Reply #5 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.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

marto2013

  • Newbie
  • *
  • Posts: 4
Re: Warning: garbage at end of string in strptime
« Reply #6 on: May 24, 2020, 01:12:12 PM »
Quote
What code page are you using? Type chcp to see what it is.
My code page is 65001.

Quote
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.
Thank you very much! I didn't know that. With single quotes, it works ;D

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3684
Re: Warning: garbage at end of string in strptime
« Reply #7 on: May 24, 2020, 01:38:15 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.
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16532
    • ExifTool Home Page
Re: Warning: garbage at end of string in strptime
« Reply #8 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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 3684
Re: Warning: garbage at end of string in strptime
« Reply #9 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
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.