Warning: Error opening file

Started by indikom, February 08, 2020, 02:28:21 PM

Previous topic - Next topic

indikom

Hi

I don't understand why I'm getting this error. Inside folder c:\_TYM\test is only one file d.jpg (in attachment). I need to change filename and creation date of the file.

exiftool "-filename<DateTimeOriginal" "-FileCreateDate<DateTimeOriginal" "-FileModifyDate<DateTimeOriginal" -d mHS%-c.%le -ext .jpg -r c:\_TYM\test


Warning: Error opening file - c:/_TYM/test/d.jpg
Error: File not found - c:/_TYM/test/d.jpg
    1 directories scanned
    0 image files updated
    1 files weren't updated due to errors

StarGeek

One problem is that your date format string is formatted poorly.  It contains no actual Date Format Codes.  Additionally, the percent signs before the c and le need to be doubled when included in a date string (see the -d (dateFormat) option).  Assuming that you want MonthHourSecond, you should use
-d "%m%H%S%%-c.%%le"

An additional problem will be the fact that you're copying DateTimeOriginal to the file time stamps, but not taking into account the fact that the -d option is going to render that operation inaccurate.  You'll want to make sure that the copy uses the original date (see the -n (printConv) option)
"-FileCreateDate<DateTimeOriginal#" "-FileModifyDate<DateTimeOriginal#"

You might also be dealing with a permission issue.  Except for the naming issue, the command worked here.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

indikom

Quote from: StarGeek on February 08, 2020, 04:49:20 PM
One problem is that your date format string is formatted poorly.  It contains no actual Date Format Codes.  Additionally, the percent signs before the c and le need to be doubled when included in a date string (see the -d (dateFormat) option).  Assuming that you want MonthHourSecond, you should use
-d "%m%H%S%%-c.%%le"

This is strange. Actually my command line looks different. The one I pasted in my original post was copied from output console and I didn't notice it doesn't look the same as the one I executed.
This is command line from my bat file:

exiftool "-filename<DateTimeOriginal" "-FileCreateDate<DateTimeOriginal" "-FileModifyDate<DateTimeOriginal" -d %Y%m%d_%H%M%S%%-c.%%le -ext .jpg -r c:\_TYM\test


In attachement is screenshot of output console. Notice that date format looks completely different.



Phil Harvey

All "%" characters need to be doubled in a .bat file

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

StarGeek

This includes doubling again the %c and %le which are already doubled in the -d format string.  See FAQ #27.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

indikom

Ok, I understand now problem with % in bat.
In order to avoid this problem I executed directly from command line:

exiftool "-filename<DateTimeOriginal" "-FileCreateDate<DateTimeOriginal" "-FileModifyDate<DateTimeOriginal" -d %Y%m%d_%H%M%S%%-c.%%le -ext .jpg -r c:\_TYM\test

On two computers with different operating systems (windows 10 and 7) and got the same error.

Warning: Error opening file - c:/_TYM/test/d.jpg
Error: File not found - c:/_TYM/test/d.jpg
    1 directories scanned
    0 image files updated
    1 files weren't updated due to errors


I suspect your answer will be that this is a permission issue, but I'd like to make sure. I attached d.jpg file in my first post. Please execute my command line against d.jpg and check if you get different result.

StarGeek

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

indikom

Quote from: StarGeek on February 09, 2020, 11:20:12 AM
Quote from: StarGeek on February 08, 2020, 04:49:20 PMExcept for the naming issue, the command worked here.

Please confirm that you executed it against d.jpg file that I've attached. I tried to solve permission problem with no luck.

StarGeek

It still works.  There is nothing wrong with the file.  The problem is on your end. 
C:\>exiftool -g1 -a -s -ext jpg -file* Y:\!temp\qqq
======== Y:/!temp/qqq/20200125_202611.jpg
---- System ----
FileName                        : 20200125_202611.jpg
FileSize                        : 3.7 MB
FileModifyDate                  : 2020:01:25 20:26:11-08:00
FileAccessDate                  : 2020:01:25 20:26:11-08:00
FileCreateDate                  : 2020:01:25 20:26:11-08:00
FilePermissions                 : rw-rw-rw-
---- File ----
FileType                        : JPEG
FileTypeExtension               : jpg
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

indikom

Quote from: StarGeek on February 09, 2020, 12:08:17 PM
It still works.  There is nothing wrong with the file.  The problem is on your end. 

Then I don't understand what is going on. I tried on 4 different computers and on every single one I have the same error:
Warning: Error opening file

Hayo Baan

Quote from: indikom on February 09, 2020, 01:45:16 PM
Quote from: StarGeek on February 09, 2020, 12:08:17 PM
It still works.  There is nothing wrong with the file.  The problem is on your end. 

Then I don't understand what is going on. I tried on 4 different computers and on every single one I have the same error:
Warning: Error opening file

Nothing wrong with the file here either; d.jpg opens just fine in exiftool. Perhaps you simply do not have the access rights to the file or it is not in the place you think it is, or ...
Hayo Baan – Photography
Web: www.hayobaan.nl

indikom

OMG I know what was wrong! And I know why you could not help me :)
I made a mistake in exiftool command line and this one execution damaged all my jpg files in my library. (I don't remember what exactly I typed) Damaged in a strange way: every jpg file got creation date: 01.01.2559
I could open every single file in image browser, but Exiftool could not open it. In order to fix it I had to change creation date in a file manager (Total Commander) then exiftool could open it.
You could not help me because the moment you downloaded attached d.jpg its creation date changed to current date.
I use word "damaged" because it is not just creation date changed to  01.01.2559. If I change date in Total Commander to 01.01.2559 then exiftool can open it, so it's not just creation date. In attachement screenshot of a list of damaged files. I can't send you an example of damaged file because even if I zip it then decompression fixes it.



StarGeek

Quote from: indikom on February 09, 2020, 07:25:11 PM
I made a mistake in exiftool command line and this one execution damaged all my jpg files in my library. (I don't remember what exactly I typed) Damaged in a strange way: every jpg file got creation date: 01.01.2559

This probably happened with your batch file and the -d option.  Since the percent signs weren't doubled, it formatted the date in a very weird way and then tried to set the file system time stamps with that malformed date.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

indikom

Quote from: StarGeek on February 09, 2020, 08:00:09 PM
This probably happened with your batch file and the -d option.  Since the percent signs weren't doubled, it formatted the date in a very weird way and then tried to set the file system time stamps with that malformed date.

That was my first suspicion. I exectued again batch with incorrectly written command but could not reproduce the exact same error. Nevertheless, thank you for trying to help.

Phil Harvey

This is crazy.  Glad you figured out the problem.

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