Resetting exported date (Win XP BAT file)

Started by mwra, May 23, 2011, 10:33:42 AM

Previous topic - Next topic

mwra

I'm exporting this CL in a BAT file on a Win XP's desktop (exiftool also on desktop):

exiftool -T -r -filename -releasedate "C:\path\to\folders" > "C:\file\path\export_list.txt  

ReleaseDate returns "CCYY:MM:DD", but I'd like - if possible - "DD/MM/CCYY". After reading the docs and searching the forum, I tried the following, this gives no file output at all:

exiftool -T -r -filename -releasedate -d %/d/%m/%Y "C:\path\to\folders" > "C:\file\path\export_list.txt  

Quoting the FMT string, this gives a file but with nothing in it:

exiftool -T -r -filename -releasedate -d %/d/%m/%Y "C:\path\to\folders" > "C:\file\path\export_list.txt  

I figure it might be because ReleaseDate isn't a date time (D/T) tag. But switching to target ProfileDateTime, a D/T tag which for the same files I've checked does have data, also returns an empty file:

exiftool -T -r -filename -profiledatetime -d %/d/%m/%Y "C:\path\to\folders" > "C:\file\path\export_list.txt  

Windows' CL can't do me a man strftime so I'm a bit stumped. I think I've two problems here:

1) the latter is formatting a D/T tag's output as I believe it should.

2) as ReleaseDate isn't a D/T tag, can I not re-format it's output (in a command line context)?

Should I give up and do the reformat in excel after export, or am I overlooking something obvious.

Thanks,

Mark

Phil Harvey

Hi Mark,

Quote from: mwra on May 23, 2011, 10:33:42 AM
I figure it might be because ReleaseDate isn't a date time (D/T) tag.

Exactly.

QuoteBut switching to target ProfileDateTime, a D/T tag which for the same files I've checked does have data, also returns an empty file:

exiftool -T -r -filename -profiledatetime -d %/d/%m/%Y "C:\path\to\folders" > "C:\file\path\export_list.txt   

This should work.  It would return an empty file only if no file exists (but then you would get a warning message).

QuoteShould I give up and do the reformat in excel after export, or am I overlooking something obvious.

You can always create a Composite tag to do what you want.  If ReleaseTime exists, you could combine them for a date/time value in the same way I do for some other tags in IPTC.pm:


%Image::ExifTool::UserDefined = (
  'Image::ExifTool::Composite' => {
    ReleaseDateTime => {
        Groups => { 2 => 'Time' },
        Require => {
            0 => 'IPTC:ReleaseDate',
            1 => 'IPTC:ReleaseTime',
        },
        ValueConv => '"$val[0] $val[1]"',
        PrintConv => '$self->ConvertDateTime($val)',
    },
  },
);
1; # end


See the config file documentation for instructions on how to activate this config file.

If ReleaseTime doesn't exist, you could drop the IPTC:ReleaseTime requirement and use "00:00:00" in the expression instead of $val[1].

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

mwra

There's definitely an issue with trying to use -d with a valid d/t tag in a file with valid tag data on a Win XP(SP3) 32-bit - or at least on this one. Still, I'll sidestep for now as it's not my immediate problem.

Managed to get the".ExifTool_config" set up, in the same location (Desktop) as the exiftools EXE. Output is unchanged. I'd link to a reference file but the files are both large, and more importantly, not mine to share.

I do see  - via Jeffrey's EXIF viewer, a mention of "Bad IPTC data tag".  These files were modified via PhotoTools which the user is ditching - I wonder if their old DAM software has screwed up some of the metadata.

As I'm running this in a day or so in an environment offline, I've knocked up an Excel s/s and will do the transform there. Much appreciate your time/help. May try this latter with some cleaner files and when I've more tinker time.

Regards

Mark

Phil Harvey

Hi Mark,

Some more details would be useful.  This problem doesn't occur on other Windows systems, so my guess is that it is some type of operational 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 ($).

mwra

Wow, thanks.

On the -d format strings. 'Hidden' under the -w entry I found the missing bit of info, that I needed to double my % in a WIN BAT file. -d "%%d/%5m/%%Y" works on a valid D/T tag. :)

As to the config file, I amde the file ".ExifTool_config" on the Desktop (alongside exiftoool.exe) and ran this in it:

%Image::ExifTool::UserDefined = (
  'Image::ExifTool::Composite' => {
    ReleaseDateTime => {
        Groups => { 2 => 'Time' },
        Require => {
            0 => 'IPTC:ReleaseDate',
        },
        ValueConv => '"$val[0] 00:00:00"',
        PrintConv => '$self->ConvertDateTime($val)',
    },
  },
);
1; # end


But then noted I don't have a 'ReleaseDateTime' tag so amended line #3 to 'ReleaseDate'.

%Image::ExifTool::UserDefined = (
  'Image::ExifTool::Composite' => {
    ReleaseDate => {
        Groups => { 2 => 'Time' },
        Require => {
            0 => 'IPTC:ReleaseDate',
        },
        ValueConv => '"$val[0] 00:00:00"',
        PrintConv => '$self->ConvertDateTime($val)',
    },
  },
);
1; # end


Either way, via this BAT file code, still no joy:

exiftool -T -r -filename -IPTC:ReleaseDate "C:\path\to\folders" > "C:\file\path\export_list.txt

Export does occur, but in "CCYY:MM:DD" form. This also fails in the same way:

exiftool -config .ExifTool_config -T -r -filename -IPTC:ReleaseDate "C:\path\to\folders" > "C:\file\path\export_list.txt

No way to tell if the config file is being used.



Phil Harvey

Quote from: mwra on May 24, 2011, 11:02:54 AM
On the -d format strings. 'Hidden' under the -w entry I found the missing bit of info, that I needed to double my % in a WIN BAT file. -d "%%d/%5m/%%Y" works on a valid D/T tag. :)

Ah yes.  This would do it.  I should have thought of this.

Quote
But then noted I don't have a 'ReleaseDateTime' tag so amended line #3 to 'ReleaseDate'.

But the idea is to create a new ReleaseDateTime tag to use in your command (with %'s doubled for the .BAT file):

exiftool -T -r -d %%d/%%m/%%Y -filename -ReleaseDateTime "C:\path\to\folders" > "C:\file\path\export_list.txt

But since there is no time, it would make sense to call this something else instead of ReleaseDateTime.

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

mwra

Edging closer, changed config to set "CustomReleaseDate"

%Image::ExifTool::UserDefined = (
  'Image::ExifTool::Composite' => {
    CustomReleaseDate => {
        Groups => { 2 => 'Time' },
        Require => {
            0 => 'IPTC:ReleaseDate',
        },
        ValueConv => '"$val[0] 00:00:00"',
        PrintConv => '$self->ConvertDateTime($val)',
    },
  },
);
1; # end


And updated CL:

exiftool -config .ExifTool_config -T -r -filename -CustomReleaseDate "C:\path\to\folders" > "C:\file\path\export_list.txt

Now I get output lines like but the date part isn't getting altered:

090511_085.tif [tab] 20115:05:20 00:00:00

Looks like ConvertDateTime($val) doesn't work. Might this be a Windows-only issue? Would it matter that some files don't have a ReleaseDate value? At present I just get a "-" for those files. That's OK as actually I do need to know of files missing such data.

FWIW, I'm on UK systems and want "dd/mm/yyyy" format for the date (single digit d or m is acceptable).

Thanks

Mark


Phil Harvey

Quote from: mwra on May 24, 2011, 12:03:05 PM
exiftool -config .ExifTool_config -T -r -filename -CustomReleaseDate "C:\path\to\folders" > "C:\file\path\export_list.txt

Now I get output lines like but the date part isn't getting altered.

Yes.  The -d option is used to format the date/time value.  You forgot this in your command.

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

mwra

That's off as if I add -d to the CL like so:

exiftool -config .ExifTool_config -T -r -d -filename -CustomReleaseDate "C:\path\to\folders" > "C:\file\path\export_list.txt

... I get the filenames only, no ReleaseDate info modified or otherwise, not even a "-":

090511_085.tif [tab]

Aha, so I need a date format string as well:

exiftool -config .ExifTool_config -T -r -d "%%d/%%m/%%Y" -filename -CustomReleaseDate "C:\path\to\folders" > "C:\file\path\export_list.txt

Good! Now I get:

090511_085.tif [tab] 20115:05:20

Now that works, I was able to test that with the config file and exiftool co-located I can safely omit the -config .ExifTool_config part and all still works.

I can also now figure (I don't know Perl) that the config is (a) declaring a new tag within the Time group, (b) constructing a d/t string literal based on ReleaseDate, (c) using ConvertDateTime to convert the string literal to D/T data. That done the -d option, with a suitable format string, gives the desired output.

I tripped on c earlier as searching the Config, Image::ExifTool API, and ExifTool app documentation, I found no mention of ConvertDateTime. I did, via a link in a forum post find a readme (http://cpansearch.perl.org/src/EXIFTOOL/Image-ExifTool-8.25/lib/Image/ExifTool/README) that explained PrintConv but not ConvertDateTime.  Had I beed able to find an explanation of the latter I thin the penny would have dropped earlier!

The latter comment isn't by way of a complaint. Rather I think I've either found a hole in the docs or missed info in them that if plugged might help someone else trying this to figure a result ... without needing so much of your kind help! The latter, I truly appreciate.

- Mark


Phil Harvey

Quote from: mwra on May 25, 2011, 03:03:07 AM
I found no mention of ConvertDateTime.

True.  This is a private function that isn't (and won't be) documented.  All I did here was to copy one of the other Composite date/time tags from the Image::ExifTool::IPTC::Composite definition:

http://cpansearch.perl.org/src/EXIFTOOL/Image-ExifTool-8.50/lib/Image/ExifTool/IPTC.pm

For some things like this, you can learn a lot by looking at the source code for examples.

All exiftool releases contain this source code, but with the Windows executable version it isn't as easy to find, so I gave a link into the cpansearch site for you above.

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

mwra

Thanks, I understand not everything can be written up in detail. Anyway, visitors searching the forums should get this thread if they search on ConvertDateTime.  :)

Appreciate the additional links too. Windows isn't my first choice - though where this task has to be done. However, I'm very impressed at the inintrusive approach of using encapsulated EXE + BAT file allowing me to do some work on someone's server with minimal footprint and without lengthy negotiations with local IT staff about what's going on.

mwra

Actually, the above process creates one problem. The use of the config file method adds a new tag "CustomReleaseDate" in the file**, but I can't get rid of that. Using the -k option exiftool tells me the tag is not writeable. I could live with the extra tag, as long as I could delete it - or at least purge it's value.

** Something, that as a non-expert user I didn't expect. I used we were piping ReleaseDate data through a transform en route to stdOut.

As it is it is safer to export the source tag's string and transform in Excel, rather than add unsuspecting metadata content. Doesn't devalue the use of the tool. I'm just being overly cautious given the havoc an ill-chosen command might wreak.

-Mark