ExifTool Forum

General => Metadata => Topic started by: Alyssa on August 07, 2014, 12:29:01 PM

Title: PNG image's attributes to JPG
Post by: Alyssa on August 07, 2014, 12:29:01 PM
Hello

I've been dealing with lots of PNG images recently but I always had the problem with these type of image's metadata, as it seems they have no attribute fields at all (No title/author/comments/subject or anything). Is there some attributes I can edit using exif tool that gets transferred to JPG? I mean, is there any attribute that I can edit with exiftool that gets transferred when I convert the images to JPG?

What I am trying to do is to preserve both the original file's create date and the original filename so I can transfer it to JPG's metadata(the File:FileCreateDate one, that gets cancelled when I convert it to JPG as it creates a new file).

I'll try to explain in another way since I am not too confident with my english.
What I want to do is:
- Copy both filename(without extension),and file:filecreatedate into an unknown attribute within the PNG)
- Convert the image to JPG using another software
- Take the metadata stored in the above-mentioned attribute and pull it to JPG's attributes (not necessarily change JPG file:filecreatedate as long as I can copy the original data into some of the JPG's attributes).
Title: Re: PNG image's attributes to JPG
Post by: Alyssa on August 08, 2014, 07:14:46 AM
*update*
Hello again
I've been thinking about a solution for this and I came to the conclusion that I could use the filename to store both the file creation date and the original filename(the only 2 informations I want to preserve).

I already have a script to rename the file based on the creation date:

C:\exiftool.exe -overwrite_original -d %%d_%%m_%%Y-%%Hx%%Mx%%S%%a%%%%-c.%%%%e "-filename<file:filecreatedate" -P .

Which convert the filename using this format:
dd_mm_yyyyy-hhxmmxssDay

After converting it to JPG I use a second script:

C:\exiftool.exe -d "%%d/%%m/%%Y custom text %%H:%%M:%%S[%%a]" -P -E "-exif:XPComment<${file:filename;s/\.jpg$//i;s/lun/[Luned&igrave;]/;s/mar/[Marted&igrave;]/;s/mer/[Mercoled&igrave;]/;s/gio/[Gioved&igrave;]/;s/ven/[Venerd&igrave;]/;s/sab/[Sabato]/;s/dom/[Domenica]/;s/_/\//;s/_/\//;s/-/ custom text /;s/x/:/;s/x/:/;s/-1//;s/-2//;s/-3//;s/-4//;s/-5//;s/-6//;s/-7//;s/-8//;s/-9//}" -overwrite_original "-exif:xpsubject<${file:filename;s/\.jpg$//i;s/lun/[Luned&igrave;]/;s/mar/[Marted&igrave;]/;s/mer/[Mercoled&igrave;]/;s/gio/[Gioved&igrave;]/;s/ven/[Venerd&igrave;]/;s/sab/[Sabato]/;s/dom/[Domenica]/;s/_/\//;s/_/\//;s/-/ D.C. Ore /;s/x/:/;s/x/:/;s/-1//;s/-2//;s/-3//;s/-4//;s/-5//;s/-6//;s/-7//;s/-8//;s/-9//}" -overwrite_original .

This one copy the filename into comments and subject field turning it from this
dd_mm_yyyyy-hhxmmxssDay
To this
dd/mm/yyyy custom text hh:mm:ss[Day]
(I can't obviously rename the file from the start using this format because of the special characters used)

But as I mentioned with this method and I don't preserve the filename.
So I thought to use a different a approach:
1 - Rename the file preserving the original filename like this:
dd_mm_yyyyy-hhxmmxssDay *original file name after*
2  - Copy only the first 22 letters(the letters forming the dd_mm_yyyyy-hhxmmxssDay part to comments/subject field as usual and turn it into the format dd/mm/yyyy custom text hh:mm:ss[Day]
3 - Copy only the 24th letter and above to Title field (xmp:description)(the 23th letter its a blank space)

I created the script to convert the format from dd_mm_yyyyy-hhxmmxssDay to dd/mm/yyyy custom text hh:mm:ss[Day] but I don't known if its possible to copy from a certain letter to another(as mentioned above,from 1th letter to the 22th and from 24th to the end of the filename).

Edit:
After some search I discovered that I can do the renaming with
"-filename<%%f $file:filecreatedate"
I can rename the files without losing the filenames.

Edit#2:
Its not good,the above put the original filename before the date,and since every file name's have a different length, there is no way to do the "first x characters" trick, I am trying to figure out how I can place it at the end of the "dd_mm_yyyyy-hhxmmxssDay" part, as well looking for a way to copy first 22 chars etc.
Title: Re: PNG image's attributes to JPG
Post by: Phil Harvey on August 15, 2014, 08:32:54 PM
Hi Alyssa,

Sorry for the delay in responding.  I'm currently on vacation.

You can place the filename after the FileCreateDate with this command:

exiftool -d "%Y-%m-%d %H%M%S" "-filename<$file:filecreatedate $file:filename" DIR

And to undo this again afterwards:

exiftool "-filecreatedate<filename" "-filename<${filename;s/.{18}//}" DIR

I think this should work, but I don't have time to test it right now.

- Phil
Title: Re: PNG image's attributes to JPG
Post by: Alyssa on August 15, 2014, 09:15:03 PM
Hi Phil
Yes that worked like a charm (had to use double % because it was a script), its simply perfect.

So in short when I have a png image I first use Script #1
C:\exiftool.exe -d "%%Y-%%m-%%d %%H%%M%%S" "-filename<$file:filecreatedate $file:filename" .

Then Script #2
C:\exiftool.exe "-filecreatedate<filename" "-filename<${filename;s/.{18}//}" .

And then the script I use to registry filename and creation date on a couple of tags using a custom format:
(Script #3)
C:\exiftool.exe -overwrite_original "-xmp:description<${filename;s/(.*)\..*/$1/}" -overwrite_original "-subject<${filename;s/(.*)\..*/$1/}" -d "%%d/%%m/%%Y Custom Text%%H:%%M:%%S[%%a]" -P -E "-exif:XPComment<${file:filecreatedate;s/\[lun\]/[Luned&igrave;]/;s/\[mar\]/[Marted&igrave;]/;s/\[mer\]/[Mercoled&igrave;]/;s/\[gio\]/[Gioved&igrave;]/;s/\[ven\]/[Venerd&igrave;]/;s/\[sab\]/[Sabato]/;s/\[dom\]/[Domenica]/}" -overwrite_original -d "%%d/%%m/%%Y Custom Text%%H:%%M:%%S[%%a]" -P -E "-exif:xpsubject<${file:filecreatedate;s/\[lun\]/[Luned&igrave;]/;s/\[mar\]/[Marted&igrave;]/;s/\[mer\]/[Mercoled&igrave;]/;s/\[gio\]/[Gioved&igrave;]/;s/\[ven\]/[Venerd&igrave;]/;s/\[sab\]/[Sabato]/;s/\[dom\]/[Domenica]/}" -overwrite_original .

Everything works perfectly, I can't express my gratitude of how deeply this will help me!
(Is there a way to merge the script 2 with the 3 by the chance? if I simply add the script 2 to the 3 it copies the altered filename before it remove the first 18 letters, same for the date being copied before being corrected)

Even like this, its simply awesome, thanks a million :)
Title: Re: PNG image's attributes to JPG
Post by: Phil Harvey on August 16, 2014, 07:55:35 AM
The last 2 commands must remain separate because you want to copy the new formatted FileModifyDate in your 3rd command.  But they may be combined into a single command line with the -execute option.  Also, there are a lot of duplicate options in your 3rd command that have no effect.  So the combined command would be:

C:\exiftool.exe "-filecreatedate<filename" "-filename<${filename;s/.{18}//}" -execute "-xmp:description<${filename;s/(.*)\..*/$1/}"  "-subject<${filename;s/(.*)\..*/$1/}" -d "%%d/%%m/%%Y Custom Text%%H:%%M:%%S[%%a]" -P -E "-exif:XPComment<${file:filecreatedate;s/\[lun\]/[Luned&igrave;]/;s/\[mar\]/[Marted&igrave;]/;s/\[mer\]/[Mercoled&igrave;]/;s/\[gio\]/[Gioved&igrave;]/;s/\[ven\]/[Venerd&igrave;]/;s/\[sab\]/[Sabato]/;s/\[dom\]/[Domenica]/}"  "-exif:xpsubject<${file:filecreatedate;s/\[lun\]/[Luned&igrave;]/;s/\[mar\]/[Marted&igrave;]/;s/\[mer\]/[Mercoled&igrave;]/;s/\[gio\]/[Gioved&igrave;]/;s/\[ven\]/[Venerd&igrave;]/;s/\[sab\]/[Sabato]/;s/\[dom\]/[Domenica]/}" -common_args -overwrite_original .

- Phil

Edit: Fixed order of commands