Deleting all but the date

Started by Karsten_M, November 03, 2010, 07:25:09 PM

Previous topic - Next topic

Karsten_M

Hello - and sorry for the dumb question, but I'm reading and trying for hours now:

I simply want to delete all metadata of all jpeg files in the folder "foo" - except the creation date. These files came out of a camera.

I tried command lines like this:
exiftool -overwrite_original -P -all= --EXIF:createdate foo

Or I tried this command line:
exiftool -@ exiftest.exif foo
with something like these lines in exiftest.exif:
-overwrite_original
-P
-all= --EXIF:createdate


But no date is preserved. I can delete all metadata - no problem. But when I try to preserve any date, either nothing happens (command line version) or all data is deleted (@ file version).
I tried so many expressions for "createdate". I tried "alldates" (would be fine)...

Any hint is highly appreciated.

Best Regards,
Karsten

PS: It would be great if I could "save" all metadata in files named original_filename.exi or something, old Exifer did so.

Phil Harvey

From the exiftool documentation:

       --TAG
            Exclude specified tag from extracted information.  Same as the -x
            option.  May also be used following a -tagsFromFile option to
            exclude tags from being copied, or to exclude groups from being
            deleted when deleting all information (ie. "-all= --exif:all"
            deletes all but EXIF information).  But note that this will not
            exclude individual tags from a group delete.  Instead, the tags
            must be recovered using the -tagsFromFile option (ie.  "-all=
            -tagsfromfile @ -artist").  Wildcards are permitted as described
            above for -TAG.


So you should do this:

exiftool -all= -tagsfromfile @ -exif:createdate

Also, your -@ ARGFILE has a problem:  You have 2 arguments on one line.  In this file you must put each argument on a separate line (ie. split up "-all=" and "--EXIF:createdate").

To save all exif information to ".exif" files, do this:

exiftool -exif -b -w exif DIR

ExifTool recognizes the ".EXIF" extension.  Does Exifer use ".EXI"?  Maybe I should also recognize this.

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

Karsten_M


Thank you very, very much, Phil!

Quote from: Phil Harvey on November 04, 2010, 07:25:51 AM
So you should do this:
exiftool -all= -tagsfromfile @ -exif:createdate
I would have never found out by myself, sorry.

Quote from: Phil Harvey on November 04, 2010, 07:25:51 AM
To save all exif information to ".exif" files, do this:
exiftool -exif -b -w exif DIR

Works also fine - thank you!

Please allow two further little questions:

1. Is there a way to write these above two commands in 1 command line?

2. Now I have a problem with time zones. Until last week we had "Summertime" MESZ, now again MEZ. Today I see for a picture, taken last week:
File Date: 10:32 - DateTimeOriginal 11:32 - Grrr. (I don't know what my watch showed when I took that picture.)
Let's Forget it.

Quote from: Phil Harvey on November 04, 2010, 07:25:51 AM
Does Exifer use ".EXI"?  Maybe I should also recognize this.

Hmm - when I delete EXIF data (or use the function "Backup" in Exifer, it makes these EXI files. Then there is a function "Restore" which writes this data back into the pictures.
When you have the list view in Exifer, there is a colum "Backup" where is a "Yes" if such EXI files exist. But - mysteriously - only when these files had been made by Exifer. I named the correspondig files of Exiftool EXI, too - but they are not recognized as such.

Thank you very much again,
Karsten

Phil Harvey

Hi Karsten,

Quote from: Karsten_M on November 04, 2010, 10:25:57 AM
1. Is there a way to write these above two commands in 1 command line?

This is complicated because in one command exiftool is extracting information and in the other it is writing information and these two modes are very distinct.  But you can resort to the -execute option to do this:

exiftool -exif -b -w exif -execute -all= -tagsfromfile @ -exif:createdate -common_args DIR

Quote
2. Now I have a problem with time zones. Until last week we had "Summertime" MESZ, now again MEZ. Today I see for a picture, taken last week:
File Date: 10:32 - DateTimeOriginal 11:32 - Grrr. (I don't know what my watch showed when I took that picture.)
Let's Forget it.

You can of course use exiftool to shift any date/time tags you want, but maybe you don't need to do this.

QuoteWhen you have the list view in Exifer, there is a colum "Backup" where is a "Yes" if such EXI files exist. But - mysteriously - only when these files had been made by Exifer. I named the correspondig files of Exiftool EXI, too - but they are not recognized as such.

Interesting.  Maybe they are different format.  Could you attach one here or email it to me (philharvey66 at gmail.com) so I can take a look?  Thanks.

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

Karsten_M

Phil,

thanks again so much. Email is on it's way.

Just a silly idea: Can ExifTool use the modification date of the file system (in my case NTFS) to fill EXIF:DateTimeOriginal?

Best Regards,
Karsten

Phil Harvey

#5
Quote from: Karsten_M on November 04, 2010, 12:58:58 PM
Can ExifTool use the modification date of the file system (in my case NTFS) to fill EXIF:DateTimeOriginal?

Absolutely:

exiftool "-exif:datetimeoriginal<filemodifydate" FILE

- Phil

P.S.  Thanks, I got the .EXI file.  It is basically a JPEG format, as opposed to the ExifTool .EXIF file which is TIFF format.
...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 ($).

Karsten_M

Thank you very much, Phil, once again.

No new question, but here my result. Maybe the one or the other looks for a similar script.

REM    Write all EXIF-Data in *.exif files (as a Back-Up)
exiftool -exif -b -w exif foo\*.jp*

REM    Delete EXIF-Data completly
exiftool -overwrite_original -P -all= -Artist="Artist" -Copyright="Copyright" foo\*.jpg

REM    Set EXIF-datetimeoriginal to the modification date of the file
REM    This avoids +- 1 hour changes because of Summertime
exiftool -overwrite_original -P "-exif:datetimeoriginal<filemodifydate" foo\*.jpg


Some notes:
- Only to use the folder ("foo" in my case) will direct Exiftool to deal with the *.exif files (made in the first statemt), too.
- Deleting all but the exif:datetimeoriginal caused a time difference of 1 hour between the file date and this exif date. So I first delete all, then...
- The last line sets the exif date to the file date. No time difference here. Note that this line also needs "-overwrite_original" (otherwise it generates new files) and -P (otherwise it won't function).

Now there left only 1 minor problem:
Warning: [minor] Error reading PreviewImage - foo/Hor.jpg

I have this with all my pictures coming from a Olympus E-P1 or a Sony NEX-5. I know this message from Geosetter which I use often and which in turn uses ExifTool. So I'm used to ignore it.

Thanks again,
Greetings from Germany,
Karsten

PS: Reading this again, I see that I cannot make a parameter from the folder (foo). Or I can use this script only for folders, not for files OR folders...
Therefore last Question: Do you see a way to exclude files of type exif? Or only to manage files of type *.jp* - but giving it a folder?

Phil Harvey

Quote from: Karsten_M on November 04, 2010, 05:11:49 PM
- Deleting all but the exif:datetimeoriginal caused a time difference of 1 hour between the file date and this exif date.

Interesting.  Could be that there is a timezone problem in the Windows Perl date/time routines I am using.  You could probably avoid this though some system setting, but it would take some trial and error.

Quote
Now there left only 1 minor problem:
Warning: [minor] Error reading PreviewImage - foo/Hor.jpg

This is very common if you edited the images or metadata with any other software.  It is extremely easy to lose the preview.

Quote
Therefore last Question: Do you see a way to exclude files of type exif?

--ext exif

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

Karsten_M

Quote from: Phil Harvey on November 04, 2010, 08:01:43 PM
Quote from: Karsten_M on November 04, 2010, 05:11:49 PM
- Deleting all but the exif:datetimeoriginal caused a time difference of 1 hour between the file date and this exif date.

Interesting.  Could be that there is a timezone problem in the Windows Perl date/time routines I am using.  You could probably avoid this though some system setting, but it would take some trial and error.

It's worse: Besides all programs - when I look at a picture made in summer, EXIF says 17:50, but file system (now, not summer) shows 16:20. So my workaround might be nonsense. The problem might be: In the EXIF there is no time zone mentioned (I think).


Quote from: Phil Harvey on November 04, 2010, 08:01:43 PM
Quote
Now there left only 1 minor problem:
Warning: [minor] Error reading PreviewImage - foo/Hor.jpg

This is very common if you edited the images or metadata with any other software.  It is extremely easy to lose the preview.

I guessed that, but it also happens with untouched pictures of my Sony NEX.

Thank you for the hint about -ext!

-karsten

Phil Harvey

Quote from: Karsten_M on November 05, 2010, 04:19:41 AM
when I look at a picture made in summer, EXIF says 17:50, but file system (now, not summer) shows 16:20.

It sounded like this changed after your ran exiftool, which is what I was thinking when I made my last comment.  But this can happen if you downloaded your images after the time change.  I have found that filesystems on memory cards do not preserve the time zone.

QuoteSo my workaround might be nonsense. The problem might be: In the EXIF there is no time zone mentioned (I think).

Correct.  But the EXIF should show the correct local time on the day the picture was taken, provided the camera clock is set properly.

Quote
it also happens with untouched pictures of my Sony NEX.

Did you use some software to download your images?  I tested this with JPEG samples from the NEX-3 and NEX-5 and I don't see any problems with the preview image.

- 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

Thanks for the sample you sent by email.

Sorry, yes I do get this warning when executing "exiftool -exif -b ..." on my samples.

The message is a bit misleading, but the reason is that the PreviewImage isn't copied with the EXIF information even though it is referenced from the EXIF maker notes because its data lies outside the EXIF segment (due to the fact that the preview, 630KB in size, is much larger than the maximum JPEG EXIF segment size of 64KB).

So the bottom line is that you must extract and preserve the PreviewImage separately if this is important to you.

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