Messy library. Too many copies. Several renames

Started by smaiderman, January 25, 2024, 12:01:08 PM

Previous topic - Next topic

smaiderman

Hi there!
Thank you for creating this tool and letting us ask.

I have a really big library. So many photos and videos, some of them with exif and otrher without exif.
I wonder if there is a command to copy the FileModifyDate, to be in the exif in all the relevant tags.

For example, i have a photo without exif that gives this info


How can I make, in a really big folder, with lots of subfolders, to edit only the files that dont have any exif info, to take the earliest date (I think "FileModifyDate" is the one), and write it in all the date fields in the exif?


My final goal is to have a single copy of every photo/video, with all the possible metadata (mainly gps and date)


Thank you so much!

Phil Harvey

If you are on Windows or Mac, FileCreateDate is available, and may be earlier than FileModifyDate.

To so what you ask, you can do this (quoting is for Windows CMD shell):

exiftool "-alldates<filecreatedate" -if "not $exif:all" -P DIR

The -P is necessary to preserve the filesystem date/time information.  You can add -r to recurse into subdirectories, and -overwrite_original to prevent preserving the "_original" backup files.

"AllDates" is a shortcut for the 3 common EXIF date/time tags (DateTimeOriginal, ModifyDate and CreateDate).

The -if condition will cause files containing any EXIF to be ignored.

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

smaiderman

Great! Thank you-.

Does filecreatedate remain the same even if you copy and paste the file to a new location? or will it change to the "paste date"?

I'm on Windows

Phil Harvey

It should remain if you use the -P option.  But you should probably test to be sure because I can't guarantee that for some filesystems like remote file servers for example.

- 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

Quote from: smaiderman on January 25, 2024, 02:06:15 PMDoes filecreatedate remain the same even if you copy and paste the file to a new location? or will it change to the "paste date"?

Yes

Seriously, I've had times when the FileCreateDate was correct and others when the FileModifyDate was correct.  These files had passed through multiple external flash drives and hard drives, as well as through other devices. I've never been observant enough to notice exactly when things have changed.  Both values should stay the same when copying/moving through the Windows desktop. Copying through the command line will probably change the date for both unless you use Robocopy with the /DCOPY:T option.

I find conflicting answers when SuperUser.com so there are probably enough edge cases to make it a problem.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

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

smaiderman

Thank you both.
So, I guess I have to check manually, and its going to take me a looooong time.

Thanks again :)

smaiderman

#7
I think I'm having an idea to make this easier.
Could exiftool add a prefix to files that have exif information and not modify anything else (I think this is -P )?

For example,

FOLDER
-1.jpg (has exif info)
-2.jpg (doenst have exif info)
-1.mov (has exif info)
-1.mkv (doesn't have exif info)

make it be

FOLDER
-(e)1.jpg
-(ne)2.jpg
-(e)1.mov
-(ne)1.mkv

?

This way, I could simply know what files I have to check if FileCreateDate or FileModifyDate is the earliest one





Also, another doubt. If I use:

exiftool '-filename<CreateDate' -d %Y%m%d_%H%M%S%%-c.%%le -r /filelocation

This will only work in all files (photo, video) WITH exif info?

Phil Harvey

#8
How about running 2 commands instead of doing this manually:

1. exiftool "-alldates<filecreatedate" -if "not $exif:all and $filecreatedate le $filemodifydate" -P DIR

2. exiftool "-alldates<filemodifydatedate" -if "not $exif:all and $filemodifydate lt $filecreatedate" -P DIR

- Phil

Edit: Fixed tt formatting
...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 ($).

smaiderman

#9
I guess it is the correct way, but as I'm just starting to know Your software, I would like to understant what we are doing, so let me try-

1. exiftool "-alldates<filecreatedate" -if "not $exif:all and $filecreatedate le $filemodifydate" -P DIR

This will, for every file in DIR that has no exif info, create the 3 main dates in the exif tag with the filecreatedate value, AND, only do this if filecreatedate is less or equal than filemodifydate (I found that le for comparisons, and Returns true if the first value is less than or equal to the second value.)

If this is true, how does the le compares dates data? It is not an absolute number. Will it work anyway?


2. exiftool "-alldates<filemodifydatedate" -if "not $exif:all and $filemodifydate lt $filecreatedate" -P DIR

This will, for every file in DIR that has no exif info, create the 3 main dates in the exif tag with the filemodifydate value, AND, only do this if filemodifydate is less (but not equal) than filecreatedate second value.


3. Can I add -r to do this to all subfolders? Where in the sentence whould this go?


4. Should I run the first command, and then the second? or is it the same line in CLI?


Thank you so much! Such a powerfull tool

Phil Harvey

You understand what is happening.

Quote from: smaiderman on January 26, 2024, 10:13:36 AMIf this is true, how does the le compares dates data? It is not an absolute number.

The "le" operator is a string comparison.  ASCII string comparisons work for standard EXIF-format date/time values.

Quote3. Can I add -r to do this to all subfolders? Where in the sentence whould this go?

Yes.  Anywhere except between -if and its condition.

Quote4. Should I run the first command, and then the second? or is it the same line in CLI?

You need to run the commands separately.  They are 2 separate commands.

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

smaiderman

What if the file contains exif that has some fields but no exifdates?

I tried with
exiftool "-alldates<filemodifydate" -if "not $exif:createdate and $filemodifydate lt $filecreatedate" -P

exiftool "-alldates<filemodifydate" -if "not $exif:alldates and $filemodifydate lt $filecreatedate" -P

and also doing the same in the createdate le modifydate script, but it didnt change anything. Still no dates in exif

Phil Harvey

#12
Very close.  The problem is that the -if will fail with a minor warning if any of the requested tags don't exist.  Add the -m option to ignore this minor warning and either of your commands should work.  (You see this warning by adding the -v option.)

- Phil

Edit: Actually, something funny is happening here.  The -m fixes it, but I didn't think it should be necessary...  I'll look into this.
...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 was fooling myself.  Your command should work if FileModifyDate is before FileCreateDate (which should actually never be the case).

- 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

Quote from: Phil Harvey on January 26, 2024, 01:30:36 PMYour command should work if FileModifyDate is before FileCreateDate (which should actually never be the case).

Windows laughs at your assertion.

C:\>exiftool -G1 -a -s  -r -fast3 -if "$FileModifyDate lt $FileCreateDate" -aaa Y:\Pictures\Camera_Pictures\SDCC
<snip>
  279 directories scanned
20057 files failed condition
63450 image files read

So, 43,393 files where FileModifyDate is less than FileCreateDate.  This dates back to my first digital camera from 1998.  Though everything from 2010 onward is duplicated, a jpeg and RAW file.

Nearly all of them would have just been copying through the desktop, not through the command line.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype