Copy Creation Date (-createdate) to File Modification date (-filemodifydate)

Started by garrickk, January 13, 2016, 05:38:34 PM

Previous topic - Next topic

garrickk

Hi all,

Brand new to this, and really just need a push.

I need to batch convert a bunch of .mov files by moving the time and date of Create Date (-createdate) into the -filemodifydate field.

No idea why I keep getting weird errors. Any suggestions? Thanks.

Garrick

Phil Harvey

Hi Gerrick,

The command would be :

exiftool "-filemodifydate<createdate" DIR

If you get any weird errors, please provide more details.

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

garrickk

Quote from: Phil Harvey on January 13, 2016, 07:41:24 PM
Hi Gerrick,

The command would be :

exiftool "-filemodifydate<createdate" DIR

If you get any weird errors, please provide more details.

- Phil

Hi Phil,

I was new, frustrated, and didn't want to type anything stupid. I normally fix this stuff on my own. My problem was looking at the examples and examining the syntax without actually thinking. In this case, using a single apostrophe (') instead of quotes (") for Linux/Mac -> Windows. Duh.

I really appreciate it! I'm rolling now.

Garrick

garrickk

Actually, I am getting an error on this command, right now under Linux. It's not a permissions issue.

Warning: Error converting value for File:FileModifyDate (ValueConvInv) - IMG_9378.MOV

When I dump the exif data for the file, I get:
File Modification Date/Time     : 2016:01:06 14:52:09-08:00
Create Date                     : 2015:12:21 16:01:22


Do I have to paste in at the end of my create data the string '-8:00' for the time zone? I tried to fill the data in, but can't get rid of the Error converting problem.

Thanks,
Garrick

Phil Harvey

Hi Garrick,

That createdate looks good.    Does the command return "1 files updated"?  If it does, then perhaps there are there two CreateDate tags in the file, and the other one is giving the error. (check with "exiftool -a -G1 -createdate 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 ($).

garrickk

Hi Phil,

Just to verify data and my command to check values:
exiftool -filemodifydate -createdate IMG_3656.mov
File Modification Date/Time     : 2015:10:23 15:33:58-07:00
Create Date                     : 2015:10:23 05:11:59


When, I then try the command, I get the following warning/error:
​exiftool "-filemodifydate<createdate" IMG_3656.mov
Warning: Error converting value for File:FileModifyDate (ValueConvInv) - IMG_3656.mov
Warning: No writable tags set from IMG_3656.mov
0 image files updated
1 image files unchanged


I should have included the "No writable tags set" warning message.

** I'm having a lot of other success with your exiftool regarding renaming, time forwarding, directory sorting, etc. Really loving it. But I've run into issues a few times with Time values that have the timezone in there. For instance, I have 4K video files from three different cameras, and they record the creation time data in slightly different variables (some really are in DateTimeOriginal or LastUpdate), and depending on the presence of '-08:00', my previous renaming script fails. I've just been finding a different variable for those.

*** One other tiny issue, not worth a thread and I have NOT searched for it yet, is files over 2GB would not process at all. This is running exiftool 10.08 on my NAS installed with Entware-ng. It's easily worked around, as I have few files that large. I'll look into it. I've read some notes from you on large files, but besides these huge videos, I've churned through Terabytes of video files so far with exiftool and it's been really fast on a TS-451+. Happy!

Garrick


Phil Harvey

Hi Garrick,

This is a real mystery.  Here is what I get:

exiftool -ver
10.09
> exiftool -filemodifydate -createdate a.mov
File Modification Date/Time     : 2013:11:05 10:34:53-05:00
Create Date                     : 2015:10:23 05:11:59
> exiftool "-filemodifydate<createdate" a.mov
    1 image files updated


What's more, if I use an improper date/time I get a different warning than you:

exiftool "-filemodifydate<filename" a.mov
Warning: Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in File:FileModifyDate (PrintConvInv) - a.mov
Warning: No writable tags set from a.mov
    0 image files updated
    1 image files unchanged


What version of ExifTool are you using?

Looking at the code, you could only possibly get this error if for some reason the Perl Time::Local module wasn't available on your system.  This is a long shot, but try this:

perl -we "use Time::Local"

If this gives you an error, then we have the culpret, and you should install Time::Local.  But Time::Local is a standard module in all Perl installations, so I couldn't imagine why it could be missing.

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

garrickk

Hi Phil,

Yeah, running the perl command gives:
syntax error at -e line 1, near "use Time:"
Execution of -e aborted due to compilation errors.


I installed 10.08 on my Qnap server with Entware-ng, which is a package of utilities, and a user on their forum gave simple steps. Sorry. Calling 'perl -v' reports I have v5.22.1 though, but many modules are missing. I can't install with CPAN because I don't have make or gcc at the moment. Certainly don't have all the DateTime stuff.

Thank you. I'll figure something out.

Garrick

Phil Harvey

Hi Garrick,

Well, at least it seems that we found the problem.  But the fact that you get a syntax error instead of a "Can't locate Time/Local.pm" error is worrisome.

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

waseem

Hello All,

I experienced this issue and followed the advice in this thread with limited success.  I was able to resolve the "Error converting value..." issue by installing the missing perl modules on my QNAP NAS. 

However, I'm now presented with a new error and I'm not sure what to make of it.

[~] # exiftool '-FileModifyDate<ModifyDate' "w.MOV" -v
======== w.MOV
Setting new values from w.MOV
The futimes function is unimplemented at /opt/lib/perl5/5.22/Image/ExifTool/Writer.pl line 5959.


I'm sure this has something to do with my environment setup or lack thereof but any insight here would be greatly appreciated.

Environment:
Linux: QNAP QTS 4.2.2
ExifTool: 10.25

Phil Harvey

Quote from: waseem on August 16, 2016, 07:58:06 PM
I was able to resolve the "Error converting value..." issue by installing the missing perl modules on my QNAP NAS. 

Could you please let us know what modules were missing?

QuoteThe futimes function is unimplemented at /opt/lib/perl5/5.22/Image/ExifTool/Writer.pl line 5959.

That line calls utime(), which should be part of the Perl standard library (from very early Perl versions).  What do these commands give you?

perldoc -f utime

perl -we 'print utime time, time, "FILE"'

where FILE is the name of any 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 ($).

waseem

Phil, thanks for all your efforts!
Quote from: Phil Harvey on August 17, 2016, 07:28:32 AM
Quote from: waseem on August 16, 2016, 07:58:06 PM
I was able to resolve the "Error converting value..." issue by installing the missing perl modules on my QNAP NAS. 
Could you please let us know what modules were missing?

I first installed ExifTool with the command:
opkg install perl-image-exiftool

Then, having experienced the "Error converting value..." issue, I installed all of the perl modules with the command:
opkg list | grep perlbase- | sed 's/ - .*//' | xargs opkg install

This stopped the issue and the Perl use local time command runs without error now, where I had seen errors before:
[~] # perl -we "use Time::Local"
[~] #


However, I still get this error:
[~] # exiftool '-FileModifyDate<ModifyDate' "w.MOV" -v
======== w.MOV
Setting new values from w.MOV
The futimes function is unimplemented at /opt/lib/perl5/5.22/Image/ExifTool/Writer.pl line 5959.
[~] #


Additional notes on some of the basic steps I've performed to troubleshoot this with my limited knowledge of Linux systems:

  • I've attempted to ensure my $PATH variable is setup correctly:
    [~] # export PATH=$PATH:/opt/bin:/opt/sbin
    [~] # echo $PATH
    /opt/bin:/opt/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin/X11:/usr/local/sbin:/usr/local/bin:/usr/local/jre/bin
  • I've removed the Perl QPKG app via the operating system's "App Center" and force reinstalled everything with opkg manager. 
  • I've self-installed the Time and ExifTool modules via CPAN over what opkg has already installed.
At this point, I'm not sure if this error is caused by the bare-bone linux distribution of the QNAP QTS software or if it's more self-inflicted as there may be conflicts between various installations of Perl and/or ExifTool.

Quote from: Phil Harvey on August 17, 2016, 07:28:32 AM
Quote from: waseem on August 16, 2016, 07:58:06 PM
The futimes function is unimplemented at /opt/lib/perl5/5.22/Image/ExifTool/Writer.pl line 5959.

That line calls utime(), which should be part of the Perl standard library (from very early Perl versions).  What do these commands give you?

perldoc -f utime

perl -we 'print utime time, time, "FILE"'

[~] #perldoc -f utime
-sh: perldoc: command not found
[~] # perl -we 'print utime time, time, "hello.pl"'
1


Thanks again for taking the time to consider this issue.

Phil Harvey

I don't know why ExifTool can't call utime() but you can directly from perl.  Are you running the same version of Perl as ExifTool (/usr/bin/perl)?  Also, maybe check to be sure that Writer.pl isn't corrupted (line 5959 just calls utime, right?).

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

mif

Seems utime/futimes fails if you are not the owner of the file, even if the rights are set to read/write for everyone.

mif

I have ran into the same problem.

I am executing the following command as a regular (non-admin) user:

/opt/bin/exiftool -if '$MIMEType =~ /^video\//' -d "/video/%Y/%Y-%m-%d/%Y%m%d_%H%M%S" -P -FileName'<${FileModifyDate}%-3c.%e' -FileName'<${MediaCreateDate}%-3c.%e' -FileName'<${CreationDate}%-3c.%e' -FileName'<${DateTimeOriginal}%-3c.%e' -FileName'<${DateTimeOriginal}_${SubSecTimeOriginal;$_.=0 x(3-length)}%-3c.%e' -i @eaDir -r /media/
Warning: [minor] Tag 'DateTimeOriginal' not defined - /media/IMG_20170415_105249.MOV
The futimes function is unimplemented at /opt/lib/perl5/5.22/Image/ExifTool/Writer.pl line 5399.


/media/ contains 9 MOV files and 1 is copied to the destination but then exiftool exits, leaving all 9 files in the /media/ directory.

The same command works when using an administrator user (not root)

perldoc -f utime
    utime LIST
            Changes the access and modification times on each file of a list
            of files. The first two elements of the list must be the NUMERIC
            access and modification times, in that order. Returns the number
            of files successfully changed. The inode change time of each file
            is set to the current time. For example, this code has the same
            effect as the Unix touch(1) command when the files already
            exist and belong to the user running the program:

                #!/usr/bin/perl
                my $atime = my $mtime = time;
                utime $atime, $mtime, @ARGV;

            Since Perl 5.8.0, if the first two elements of the list are
            "undef", the utime(2) syscall from your C library is called with a
            null second argument. On most systems, this will set the file's
            access and modification times to the current time (i.e.,
            equivalent to the example above) and will work even on files you
            don't own provided you have write permission:

                for my $file (@ARGV) {
                    utime(undef, undef, $file)
                        || warn "Couldn't touch $file: $!";
                }

            Under NFS this will use the time of the NFS server, not the time
            of the local machine. If there is a time synchronization problem,
            the NFS server and local machine will have different times. The
            Unix touch(1) command will in fact normally use this form instead
            of the one shown in the first example.

            Passing only one of the first two elements as "undef" is
            equivalent to passing a 0 and will not have the effect described
            when both are "undef". This also triggers an uninitialized
            warning.

            On systems that support futimes(2), you may pass filehandles among
            the files. On systems that don't support futimes(2), passing
            filehandles raises an exception. Filehandles must be passed as
            globs or glob references to be recognized; barewords are
            considered filenames.

            Portability issues: "utime" in perlport.



touch hello.pl
perl -we 'print utime time, time, "hello.pl"'
1


/opt/bin/exiftool -ver
10.08


/opt/bin/perl --version

This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-linux-glibc

Phil Harvey

Thanks for the post, but I still don't understand a couple of things:

1. Do you have any idea why utime would behave differently when run as administrator?  Are your PERL5LIB settings the same in both cases?

2. Why is the error reporting line 5399?  The utime call is on line 5913 in ExifTool 10.08.

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

mif

Quote1. Do you have any idea why utime would behave differently when run as administrator?  Are your PERL5LIB settings the same in both cases?

I don't know.  How would I check PERL5LIB settings?

Quote2. Why is the error reporting line 5399?  The utime call is on line 5913 in ExifTool 10.08.

This is interesting.  /opt/lib/perl5/5.22/Image/ExifTool.pm contains $VERSION = '10.08';, however, /opt/lib/perl5/5.22/Image/ExifTool/Writer.pl does not have any information in the file to associate it with any specific version.

The library and perl were installed using entware-ng.

Phil Harvey

Quote from: mif on April 20, 2017, 10:37:14 AM
How would I check PERL5LIB settings?

printenv PERL5LIB

Quote/opt/lib/perl5/5.22/Image/ExifTool.pm contains $VERSION = '10.08';, however, /opt/lib/perl5/5.22/Image/ExifTool/Writer.pl does not have any information in the file to associate it with any specific version.

True.  Here is what Writer.pl should look like for version 10.08:

% ls -l Image-ExifTool-10.08/lib/Image/ExifTool/Writer.pl
-rw-r--r--  1 phil  staff  267457 Dec 22  2015 Image-ExifTool-10.08/lib/Image/ExifTool/Writer.pl
% md5 Image-ExifTool-10.08/lib/Image/ExifTool/Writer.pl
MD5 (Image-ExifTool-10.08/lib/Image/ExifTool/Writer.pl) = fc32e5a53d818fc94ae7dcd543f1f3af


Also note that I have just released ExifTool 10.50 with improved handling of utime errors.

QuoteThe library and perl were installed using entware-ng.

I suggest trying to un-install this version, then install 10.50 using the standard install technique.

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

mif

PERL5LIB is not set

I did a diff of Writer.pl on my system and 10.08 download and it looks like they stripped all first column comments.  Otherwise the files are the same.

I will see if I can use the newest version.

mif

I just tried version 10.50 and it works.

exiftool now displays:

Warning: [minor] Tag 'DateTimeOriginal' not defined - /media/IMG_20170415_105249.MOV
Warning: The futimes function is unimplemented - /media/IMG_20170415_105249.MOV


and continues to work.

Phil Harvey

So the -P option likely isn't working for you, but at least the new version now continues running if futimes is missing.  Unforunately it still doesn't answer the question about why futimes isn't available for you when not running as administrator.

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

Phil Harvey

I have come up with a patch that should work around this problem and allow file times to be set even when futimes is not available.  ExifTool 10.51 will contain this patch.

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

mif


Phil Harvey

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

mif

I gave it a few tries.  Here are the results:

The original command no longer warns me about unimplemented futimes but -P still does not work.  The date/time is set to the current date/time.

I tried the following command on the destination directory:

exiftool "-filemodifydate<CreationDate" /destination

It works and sets the date/time to the CreationDate

The original command is executed on files that belong to a different user/group, but all users have read/write permissions.
The destination file is owned by the executing user/group.

I tried changing the owner/group of the source file to the executing user but -P still did not work.

For testing, I used a file where I set the date/time using the above exiftool command.

Phil Harvey

Darn.  OK, thanks.  I'll have another look at this then.  It is a bit difficult because I can't replicate your situation on any of my machines, but maybe you have given me enough information to figure this out.

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

mif

I did more testing.

I did change a few things.  I simplified my test.  I copied .MOV file to my home directory and I used exiftool "-FileModifyDate<CreateDate" ~ to test.

.MOV file mode is rw for owner, group, users

.MOV file is owned by executing user and group.

Executing as the owner (admin).

version 10.50 failed with futimes unimplemented error.
version 10.51 worked.

.MOV file is owned by another user.

Executing as a non-owner user (admin).

version 10.50 and 10.51 failed with a generic error.

Executing as the owner (non-admin)

version 10.50 failed with futimes unimplemented error.
version 10.51 worked.

This tells me that your patch does fix the futimes problem.

I also tested the -P option and it appears to work as well.  I think in my previous test I made a mistake.  I think I copied the files before testing and did not realize the copy would update modified date.

Phil Harvey

Thank you very much for looking into this in more detail.  This saves me a lot of head scratching.

I'm glad to hear that it is working as expected.

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

Netson

I have the same question. It seems it's a same bug.

I use qnap too.

When I set FileModifyDate, it report
Warning: Error converting value for File:FileModifyDate (ValueConvInv)

I installed exiftool from Entware-ng, too, and now the version of exiftool is 10.6 in Entware-ng.

I run 'perl -we "use Time::Local"' and got a "Can't locate Time/Local.pm" error,

also, perl -we 'print utime time, time, "FILE"' returns 1.

At first, I use root user,and I change file owner to root user, It is useless.

Netson

OK, I fixed it.

the perl from Entware-ng miss module Time and File::RandomAccess.

While I installed Time and File::RandomAccess it was ok.

Phil Harvey

Yes, Time::Local is important, and standard on most systems.  File::RandomAccess is part of the ExifTool distribution.

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