Correct syntax to limit scope of files modified?

Started by tenthumbs, January 10, 2018, 04:24:53 PM

Previous topic - Next topic

tenthumbs

Hi. Total noob here, sorry for having to ask the obvious, please be gentle...

I'm running ExifTool 10.74 on a Mac (macOS 10.12.4).

I'm looking to perform a simple ShiftTime operation on a set of files (a very common scenario, I'm sure: went on vacation, forgot to set multiple cameras' time zone for local time; now, all time stamps are off by 7 hours).  It seems I need to run the 'AllDates' shortcut (+=7) on these files. OK, got the concept...

Before running this on all 12,000 images from my last vacation, I want to be sure I have the syntax and other stuff correct (I especially want to make sure I don't modify all the files on my computer...).  So I have some test files on an external volume to play with.  My questions here are about the appropriate syntax to 1) get the desired ShiftTime result, and 2) ensure the ShiftTime operation only points to the files on that external volume, not everything everywhere on the computer.

My concern is amplified by my very limited experience running terminal commands (as you will see here).

So, I can launch the Terminal app, in that I believe the correct syntax to adjust all Exif dates by +7 hours would be:

exiftool -AllDates+=7  Correct?

But if I want to ensure this only operates on the files located on an external drive named "FooDrive", what's the best way to accomplish that?

In the documentation for the Date/Time Shift Feature, the example shown is:

exiftool -AllDates-=1 DIR

However, I don't understand the use of the "DIR" parameter/switch(?) there.  Yeah, I presume its a variable for the directory...but how exactly is this used in practice?

Does one launch the Terminal app, and then before invoking exiftool, navigate to the target directory (using cd /Volumes/FooDrive and then run ExifTool  -AllDates+=7 DIR?

Or, lets say the target files are on an external volume (volume name: FooDrive) in a directory (directory name: HitMe). Would you just launch Terminal, not navigate to the target directory in Terminal, just launch ExifTool and enter exiftool -AllDates+=7 FooDrive/HitMe ?

That's just a wild guess above about the correct syntax to point it to a directory on an external volume, so I'm sure it's not right.  Is that close?  Is that the right idea?  Can anyone provide the correct syntax (and confirm the steps)?

I hope the above makes sense.  Many thanks in advance for your help!!!

StarGeek

#1
Quote from: tenthumbs on January 10, 2018, 04:24:53 PM
Does one launch the Terminal app, and then before invoking exiftool, navigate to the target directory (using cd /Volumes/FooDrive and then run ExifTool  -AllDates+=7 DIR?

Or, lets say the target files are on an external volume (volume name: FooDrive) in a directory (directory name: HitMe). Would you just launch Terminal, not navigate to the target directory in Terminal, just launch ExifTool and enter exiftool -AllDates+=7 FooDrive/HitMe ?

Either approach will work, though in the first case you would replace DIR with a dot .  The dot represents the current directory on Mac/Linux/Windows.

So you could either CD to /Volumes/FooDrive and run
exiftool -AllDates+=7 .

or from any directory run
exiftool -AllDates+=7 /Volumes/FooDrive

That will process all files in /Volumes/FooDrive and leave behind "_original" backup files.  It will not process files in any subdirectory.  You would need to add -r to do that.  If you think you have your command correct and don't want backup files to be created, you can add -overwrite_original to the command.
* 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).

tenthumbs

Thank you - that's very helpful (and it seems to be working - mostly - as I'd expect).

Of course now I'm hitting a different wrinkle: the updated files are getting their (OS level) Creation Date/Modification date set to today/now.
I understand that from an engineering standpoint, this might be technically correct behavior.  But it's is not what I wanted for the outcome.

Is there a switch/parameter/option to preserve the original Creation/Modification dates/time, but to shift those (in my case +7 hours) to keep them in sync with the newly shifted Exif values?  That is, shift all Exif values +7 hours and also shift all (Mac OS) File Creation and File Modification dates the same +7 hours?

Many thanks again!

tenthumbs

Maybe I have found part of the answer to my question above...

In the docs, I see this:

QuoteNote: Not all date/time information is covered by the AllDates shortcut. Specifically, the filesystem date/time tags are not included, and this command will reset FileModifyDate to the current date/time as it should when the file is modified, unless either the -P option is used, or FileModifyDate is set to something else. To shift FileModifyDate along with the other tags, add -FileModifyDate-=1 to the command above.

I am not finding any other references in the docs to "the -P option" but this implies that if I include this "-P option", then both (system level) File Creation and File Modification dates would NOT be changed to todays date, rather those dates would be preserved (unchanged)....is that correct?

Then there's that second reference to adding "-FileModifyDate-=1", which I assume adjusts the OS level value for modification date, not an Exif value - correct?
The naming convention suggests that there's also a "FileCreateDate" value (which I'd assume corresponds to the OS level "Creation date"), and which could also be shifted as in the previous line.  Is that correct?

So, if my goal is to shift all Exif dates +7 hours, and also shift the (OS level) FileModifyDate +7 hours (for all files in the current directory), to keep all those values aligned at +7 hours, would that be:

exiftool -AllDates+=7 -P .

or, would that be:

exiftool -AllDates+=7 -FileModifyDate+=7 -FileCreateDate+=7 .

Finally, a syntax question, about that trailing "."

QuoteThe dot represents the current directory on Mac/Linux/Windows.

Does that dot always go at the very end of the string (that is, it'll only work to limit the changes to files in the current directory only if the dot is the last character in the command line)?
As I start adding more switches, I want to ensure the results only apply to the current directory.

Many thanks again for all the help!

Phil Harvey

Here is the -P option description in the application documentation.

Your last command should do what you want (shift EXIF date/time plus system date/time tags by 7 hours).

About the order of the arguments... from the last sentence in the first paragraph of the OPTIONS section of the application documenation:

        Contrary to standard practice, options may appear after
        source file names on the exiftool command line.


The "." is a source file name (ie. all files in the current directory).

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

tenthumbs

Great - thank you - it does seem to be working.

One (I think) final question:

I'm using this: exiftool -AllDates+=7 -FileModifyDate+=7 -FileCreateDate+=7 –overwrite_original .

It seems to be correctly shifting the times, but the "overwrite_original" option (suggested above by StarGeek) does not seem to be working.
I'm getting new files with "_original" appended to the file name, plus this generic error: 1 files weren't updated due to errors

See anything wrong with my syntax?

exiftool -AllDates+=7 -FileModifyDate+=7 -FileCreateDate+=7 –overwrite_original .

Phil Harvey

That's not a normal dash in front of -overwrite_original.  (You probably cut and pasted and got some funny Unicode look-alike character instead.)

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

tenthumbs

Yep, that did the trick.  It figures (I know, beware the perils of copy/paste...).

Another big thank you for the help and for creating this powerful and useful tool!

StarGeek

Quote from: tenthumbs on January 10, 2018, 07:42:15 PM
Yep, that did the trick.  It figures (I know, beware the perils of copy/paste...).

Sorry, that was my error.

Normally, in my clipboard history program, there's a copy of -overwrite_original because I copy/paste it so often.  I went in there, grabbed the first copy and pasted it.  Unfortunately, just a couple days ago someone else used and nDashoverwrite_original in their post and that was what was in the history. 

Again, sorry, my mistake.  I'll fix my original post.
* 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).

tenthumbs

No worries - it serves as a good lesson to type the characters even when feeling lazy.  Greatly appreciate all the help!!!

(This has been on my "fix that @#%! thing" list for months...)  8)

tenthumbs

Hi again.  Back from another foreign trip.  This time, I remembered to adjust my camera's date/time stamp upon arrival, so got correct date/time metadata for the first day. Feeling ever-so-smart, the next day I crossed into another time zone and forgot for a few hours before re-adjusting the timezone.  So, I have a small number of photos I need to shift all values +1 hour.

Remembering my previous experience, I checked my notes, and came back here, with mixed results.

The goal is to shift all values (Exif timestamps and OS-level File Creation/Modification dates) +1 hour.

I'm using the following command: exiftool -AllDates+=1 -FileModifyDate+=1 -FileCreateDate+=1 -overwrite_original .

The results are mixed. It appears to be correctly shifting the OS Modification Date, but the OS Creation date is changing to the current date/time.  I haven't examined the Exif dates but assume those are correct.

Additional oddity: I'm getting the following error message in Terminal:

Error: File not found - ./._IMG_4297.JPG
Error: File not found - ./._IMG_4298.JPG
Error: File not found - ./._IMG_4299.JPG
    1 directories scanned
    6 image files updated
    3 files weren't updated due to errors


This occurs when processing 6 JPG files (the three named files above correspond to the last three files); if there are a different number of files in the directly, the 'error' files may be a different number, but there's always some number of 'errors').  And the OS File Creation dates are getting set to today/now, rather than just shifting +1 hour.

(FWIW I did check and I'm pretty sure all my dash characters are simple dashes (hyphens).)

Any idea where I'm going wrong here?  Thanks again for the help!

tenthumbs

Update: Found a fix.

The behavior described above was occurring (consistently) when operating on an external volume (hard drive connected via USB  hub).

I tried the exact same procedure after moving the files to the boot drive, and all worked as expected: no errors, and all dates shifted as expected.

Hmmm.

I'm speculating that there was some time lag issue when accessing the external drive, which interfered with the execution of the operations.  Hmmm.

In any case, I'm good, my files have been tweaked as I had wanted, no additional intervention required.
Thanks again for this useful tool.

Alan Clifford

Quote._IMG_4297.JPG

That is not a photo but a file created by the operating system when you view a file using finder, or maybe preview, when the file is on a disk filing system such as FAT.  For example, on an sd card.

The presence of such a file on the sd card really upset one of my cameras!