ExifTool Forum

ExifTool => Newbies => Topic started by: mcjtom on January 02, 2020, 12:13:32 AM

Title: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: mcjtom on January 02, 2020, 12:13:32 AM
Hi,

I was hoping that more experienced users could check my attempts, advise me if I'm on the right track and perhaps point me out to a better way of accomplishing what I'm trying to do.

I'm trying to create a series of Windows 10 shortcuts and move them to:

C:\Users\<Myusername>\AppData\Roaming\Microsoft\Windows\SendTo

so that I could later use them in File Explorer right-click SendTo context menu on selected files (and/or all files in selected folders and subfolders, if that's possible).

I'm also trying to restrict the ExifTool operation to output image files (TIFF, JPG, PNG, GIF) and prevent accidentally changing anything in RAW files (RAF and CR2 in my case).  It would be also nice if I could prevent or pause the script if any of the selected files are ReadOnly, but I can't figure out how to do that.  I'm also a bit confused with use of double apostrophes when writing ExifTool options in the Target field of Windows Shortcut.

For 'Add the artist and copyright' script, I can't figure out how to write to JPG/File Comment field (just like the one that can be edited in FastStone Viewer).  Also, since I'm attempting to write Artist and Copyright to EXIF. IPTC and XMP (for good measure, I suppose...) I need to write the same text 3 times - could that be simplified by writing it once and then copying to 2 other sets of fields?

My draft scripts for the Target field in Windows 10 Shortcuts are as follows:

EXIFTool - Strip metadata
"C:\Program Files\Digital Light & Color\Picture Window Pro 8\exiftool.exe" -all= --ext "CR2" --ext "RAF" -r -overwrite_original -progress -k

EXIFTool - Strip ICC profile
"C:\Program Files\Digital Light & Color\Picture Window Pro 8\exiftool.exe" -icc_profile= --ext "CR2" --ext "RAF" -r -overwrite_original -progress -k

EXIFTool - Add artist and copyright
"C:\Program Files\Digital Light & Color\Picture Window Pro 8\exiftool.exe" -EXIF:Artist="Maciej Tomczak" -EXIF:Copyright="(c) Maciej Tomczak / www.phototramp.com" -IPTC:By-Line="Maciej Tomczak" -IPTC:CopyrightNotice="(c) Maciej Tomczak / www.phototramp.com" -XMP:Creator="Maciej Tomczak" XMP:Rights="(c) Maciej Tomczak / www.phototramp.com" --ext "CR2" --ext "RAF" -r -overwrite_original -progress -k

EXIFTool - Embed sRGB ICC
"C:\Program Files\Digital Light & Color\Picture Window Pro 8\exiftool.exe" -icc_profile<="C:\Program Files\Digital Light & Color\Picture Window Pro 8\Profiles\sRGB Color Space Profile.icm" --ext "CR2" --ext "RAF" -r -overwrite_original -progress -k

EXIFTool - Embed AdobeRGB ICC
"C:\Program Files\Digital Light & Color\Picture Window Pro 8\exiftool.exe" -icc_profile<="C:\Program Files\Digital Light & Color\Picture Window Pro 8\Profiles\AdobeRGB1998.icc" --ext "CR2" --ext "RAF" -r -overwrite_original -progress -k


Many thanks!




Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: mcjtom on January 02, 2020, 01:56:40 AM
Some additional questions:

- would using overwrite_original_in_place be any better (or worse as it may be slower) in my case?  I'm not sure if each selected file is being parsed to ExifTool and overwritten in turn or the .tmp files are created for all selected files and then renamed?

- would -m option be useful for my scenario?  Some of the image files that I want to process may be pretty large (especially uncompressed TIFFs).

- would -fast command make things any faster on multiple file selections?  Is there anything else that would make my scripts (once sorted out) run faster?

Cheers!
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: mcjtom on January 02, 2020, 02:35:23 AM
I just discovered that Windows Shortcut Target field is limited to 260 characters, so, for example, my Add artist and copyright script, even it it works, is too long...
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: StarGeek on January 02, 2020, 07:23:35 AM
I can't offer any advice with regards to the send to part, except maybe to create a .BAT file instead of a shortcut to work around the character limit.  Though you still will have to deal with Windows command line limit of something like 8,000 characters.  Just something to keep in mind when you select a lot of files.

I'm also a bit confused with use of double apostrophes when writing ExifTool options in the Target field of Windows Shortcut.

Any argument that contains a space or a less/greater than symbol needs double quotes " around it.  If you are doing something like a string comparison in an -if statement, you need single quotes around the compare string.  For example (extra spaces added to show where single and double quotes end)
-if " $Artist eq 'Pablo Picasso' "

Quote
For 'Add the artist and copyright' script, I can't figure out how to write to JPG/File Comment field (just like the one that can be edited in FastStone Viewer).

If I recall correctly, Faststone has very limited metadata capabilities.  The field to use would be Comment.  A word of warning though.  It is not a safe place to put data.  Some programs will overwrite any data placed there with their own text.  For example, Photoshop used to write "File written by Adobe Photoshop" in that field.  And anything previously saved there would be lost.

Quote
Also, since I'm attempting to write Artist and Copyright to EXIF. IPTC and XMP (for good measure, I suppose...) I need to write the same text 3 times - could that be simplified by writing it once and then copying to 2 other sets of fields?

You can't write a field and copy that data to another filed in the same command.  But you can either create a shortcut tag (see the example.config file (http://ttps://exiftool.org/config.html) for details) or use the MWG:Creator tag (https://exiftool.org/TagNames/MWG.html) which will write to EXIF:Artist, IPTC:By-line, and XMP-dc:Creator all at the same time.  As an example, I use this as my shortcut to write all three at once.
    MyCreator   => ['EXIF:Artist','IPTC:By-line','XMP-dc:Creator'],

- would using overwrite_original_in_place be any better (or worse as it may be slower) in my case?  I'm not sure if each selected file is being parsed to ExifTool and overwritten in turn or the .tmp files are created for all selected files and then renamed?

ExifTool always creates a temp file as it processes files.  By default, it add _original the original file and renames the temp file to the original name.  The Overwrite_Original option (https://exiftool.org/exiftool_pod.html#overwrite_original) "…is implemented by renaming a temporary file to replace the original. This deletes the original file and replaces it with the edited version in a single operation."   The overwrite_original_in_place option (https://exiftool.org/exiftool_pod.html#overwrite_original_in_place) opens "…the original file in update mode and replacing its data with a copy of a temporary file before deleting the temporary".

The overwrite_original_in_place should only be used in very specific circumstances.  As mentioned in the docs, it will save some Mac OS data.  And some people using Network Attached Storage (NAS) have used it in some other special cases.  It is slower as mentioned in the docs.  Also, IMO, it's less safe to use, because if something like a power outage while writing happened, you might lose the image.  (Note to self, stop using the computer, the air conditioner, and the vacuum at the same time)

Quote
- would -m option be useful for my scenario?

That option only suppressed the reporting of minor errors.  It would be useful if you were adding IPTC data that was larger than  the spec calls for, which is common.   But extremely large TIFF files (bigger than 4 gigs I think?) might require adding the -api LargeFileSupport option (http://).

Quote
- would -fast command make things any faster on multiple file selections?  Is there anything else that would make my scripts (once sorted out) run faster?

Fast only helps if the command doesn't have to actually read data in the file.  For example, reading the OS file system dates or doing a rename that doesn't involve embedded data.
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: Phil Harvey on January 02, 2020, 07:35:53 AM
StarGeek responded while I was composing my answer, but here is what I wrote anyway:

It would be also nice if I could prevent or pause the script if any of the selected files are ReadOnly, but I can't figure out how to do that.

You're getting too complicated here for a Windows Shorcut.  I would recommend using a .bat file instead.  To do what you want you could do something like this.  (Hopefully the FilePermissions tag reflects the write permissions you are looking for in Windows):

Code: [Select]
exiftool -fast4 -if "$filepermissions =~ /^.w/" %*
if not errorlevel 0 (
echo Some files are write protected
exit /b %errorlevel%
)
exiftool <do something here> %*

Quote
I'm also a bit confused with use of double apostrophes when writing ExifTool options in the Target field of Windows Shortcut.

This may be a bit less confusing if you use .bat files instead.

Quote
For 'Add the artist and copyright' script, I can't figure out how to write to JPG/File Comment field (just like the one that can be edited in FastStone Viewer).

This is likely either the ExifTool Comment or UserDescription tag.

Quote
I need to write the same text 3 times - could that be simplified by writing it once and then copying to 2 other sets of fields?

In a .bat file you can assign this to a variable and use that variable 3 times in the command.

- would using overwrite_original_in_place be any better (or worse as it may be slower) in my case?  I'm not sure if each selected file is being parsed to ExifTool and overwritten in turn or the .tmp files are created for all selected files and then renamed?

The -overwrite_original_in_place  option mechanics write to a temporary file exactly the same as without the option.  The difference is that after the temporary file is successfully written its data is copied into the target file instead of simply renaming it.

Quote
- would -m option be useful for my scenario?  Some of the image files that I want to process may be pretty large (especially uncompressed TIFFs).

This would only make a difference if you are getting minor errors or warnings when writing.  It is advisable to understand what the errors are before using -m.

Quote
- would -fast command make things any faster on multiple file selections?  Is there anything else that would make my scripts (once sorted out) run faster?

The -fast option has no effect when writing.

I just discovered that Windows Shortcut Target field is limited to 260 characters, so, for example, my Add artist and copyright script, even it it works, is too long...

The .bat file also gets around this problem.

- Phil
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: mcjtom on January 03, 2020, 01:08:10 AM
Many thanks for all your detailed help!  Here are my SendTo shortcuts scripts (http://www.jonathansachs.me/phpbbBB3/viewtopic.php?f=5&t=2326) that seem to work the way I wanted them to

Cheers!
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: StarGeek on January 03, 2020, 02:13:15 AM
One more hint.  Instead of
C:\Users\<yourusername>\AppData\Roaming\Microsoft\Windows\SendTo
you could use the %APPDATA% ENV variable
%APPDATA%\Microsoft\Windows\SendTo
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: mcjtom on January 03, 2020, 03:52:27 AM
Thanks again!

There is one more SendTo script whose intention is to make mostly JPGs as small and clean as possible by stripping as much of metadata as practical.

"C:\Program Files\Digital Light & Color\Picture Window Pro 8\exiftool.exe" -all= -icc_profile= -ThumbnailImage= --ext "CR2" --ext "RAF" -r -overwrite_original -progress -k

What I'm confused about is -ThumbnailImage= vs. -Preview= vs. -PreviewImage=

Should I use -Preview= to remove all embedded images, if any?  Is there anything else that can be removed, but I've missed?

There is one more idea: since I'm trying to remove everything but the image, why not to obscure the file dates as well... Would -AllDates= work for that purpose?

Cheers!
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: mcjtom on January 03, 2020, 04:40:56 AM
Another question still: the following Windows Shortcut script adds EXIF Artist and Copyright to image files, including RAW (Fuji RAF in my case).  I tried it on some 300 files and it works, but seems slow especially if RAF are being written to.  Is there a way to make it faster?

"C:\Program Files\Digital Light & Color\Picture Window Pro 8\exiftool.exe" -EXIF:Artist="Maciej Tomczak" -EXIF:Copyright="Copyright © 2020 Maciej Tomczak / www.phototramp.com / Unlicensed use prohibited" -r -overwrite_original -progress -k
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: mcjtom on January 03, 2020, 05:02:04 AM
And the reverse problem: if I would like to add just Artist and Copyright info to RAW files, and try not to touch anything else, including the file date(s), would -P option be sufficient as in the example below?

"C:\Program Files\Digital Light & Color\Picture Window Pro 8\exiftool.exe" -EXIF:Artist="Maciej Tomczak" -EXIF:Copyright="Copyright © 2020 Maciej Tomczak / www.phototramp.com / Unlicensed use prohibited" -P -r -overwrite_original -progress -k
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: Phil Harvey on January 03, 2020, 07:14:58 AM
"C:\Program Files\Digital Light & Color\Picture Window Pro 8\exiftool.exe" -all= -icc_profile= -ThumbnailImage= --ext "CR2" --ext "RAF" -r -overwrite_original -progress -k

What I'm confused about is -ThumbnailImage= vs. -Preview= vs. -PreviewImage=

Should I use -Preview= to remove all embedded images, if any?  Is there anything else that can be removed, but I've missed?

There is no tag called preview.  I think you mean -preview:all= which removes all tags in the preview group.  But you are already using -all=, which should cover all of this (for JPG images anyway).  BTW, doing -all= is dangerous for all RAW files types, so I would advise being more restrictive and including only the file types you want instead of just excluding CR2 and RAF.

Quote
There is one more idea: since I'm trying to remove everything but the image, why not to obscure the file dates as well... Would -AllDates= work for that purpose?

That will remove common EXIF dates.   Use -time:all= to remove more.  But again, your command has -all=, which would cover this.

Another question still: the following Windows Shortcut script adds EXIF Artist and Copyright to image files, including RAW (Fuji RAF in my case).  I tried it on some 300 files and it works, but seems slow especially if RAF are being written to.  Is there a way to make it faster?

No.  The write speed is essentially determined by the size of file, and should be about the same speed as copying the file.

And the reverse problem: if I would like to add just Artist and Copyright info to RAW files, and try not to touch anything else, including the file date(s), would -P option be sufficient as in the example below?

"C:\Program Files\Digital Light & Color\Picture Window Pro 8\exiftool.exe" -EXIF:Artist="Maciej Tomczak" -EXIF:Copyright="Copyright © 2020 Maciej Tomczak / www.phototramp.com / Unlicensed use prohibited" -P -r -overwrite_original -progress -k

Yes.

- Phil
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: mcjtom on January 03, 2020, 08:35:34 AM
Thanks again!  So if there is the command -all=, is there still need for -ThumbnailImage= or -icc_profile= if I want to remove as much metadata as possible and any other embedded info without breaking the file (mostly jpgs and tifs, not RAW)?

Also, if instead of excluding certain types of RAW I include those image files that I want the command to operate on, how do I make sure that I can operate on folders and subfolders still?  Would something like that work?:

-all= -ext "jpg" -ext "jpeg" -ext "tif" -ext "tiff" -ext "png" -ext "gif" -r

Cheers!
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: Phil Harvey on January 03, 2020, 09:01:47 AM
Thanks again!  So if there is the command -all=, is there still need for -ThumbnailImage= or -icc_profile= if I want to remove as much metadata as possible and any other embedded info without breaking the file (mostly jpgs and tifs, not RAW)?

The -all= will remove any deletable tag that isn't marked as "unsafe".  ICC_Profile is an "unsafe" tag.  "Unsafe" tags are indicated by an exclamation point in the "Writable" column of the tag name documentation (https://exiftool.org/TagNames/).  These particular tags are found in the Extra tags (https://exiftool.org/TagNames/Extra.html) table of the documentation.

Quote

Also, if instead of excluding certain types of RAW I include those image files that I want the command to operate on, how do I make sure that I can operate on folders and subfolders still?  Would something like that work?:

-all= -ext "jpg" -ext "jpeg" -ext "tif" -ext "tiff" -ext "png" -ext "gif" -r

Yes.  But see FAQ 7 (https://exiftool.org/faq.html#Q7) for more information about deleting all metadata from a TIFF image.

- Phil
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: StarGeek on January 03, 2020, 10:18:06 AM
There is one more idea: since I'm trying to remove everything but the image, why not to obscure the file dates as well... Would -AllDates= work for that purpose?

Do you mean the OS file system dates?  FileModifyDate and FileCreateDate?  If so, these cannot be removed. FileModifyDate will be automatically changed when you edit the file to the time it gets modified.  FileCreateDate would have to be set separately, either to some date you choose or to the time of the edit with -FileCreateDate=now.
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: mcjtom on January 03, 2020, 11:10:25 AM
Thanks Phil and StarGeek!

So if I get it correctly -all= when used on JPG will remove embedded previews and thumbnail as they are not 'unsafe' - ergo -ThumbnailImage= is redundant?  For ICC profile there need to be another command -icc_profile= to get it deleted as it is considered unsafe?
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: Phil Harvey on January 03, 2020, 11:27:23 AM
Yes.
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: mcjtom on January 03, 2020, 02:55:24 PM
I'm pushing my luck...

There is another Windows SendTo Shortcut script that extracts all preview/thumbnail images and places them in the same folder as the input file.  It works, but I would prefer to create subfolders for the extracted images.  No matter what I try, I'm getting an error...

"C:\Program Files\Digital Light & Color\Picture Window Pro 8\exiftool.exe" -a -b -W %d%f.%e_%t%-c.%s -progress -r -k -preview:all
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: StarGeek on January 03, 2020, 03:00:06 PM
The %d is the directory of the file being proccessed, including trailing slash.  The %f is the name of the file without the extension.  Put the name of your subfolder between them.
%dSubfolder/%f
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: mcjtom on January 03, 2020, 03:12:38 PM
Awesome!  Thanks!
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: mcjtom on January 04, 2020, 05:35:53 AM
Hmm... Another porblem that I'm too ignorant to solve.  Here is the SendTo Shortcut script that I believe reads OS file creation date and sticks its year into the EXIF:Copyright tag. 

%PWP%\exiftool.exe -EXIF:Artist="Maciej Tomczak" -d %Y "-EXIF:Copyright<Copyright (c) $FileCreateDate Maciej Tomczak / www.phototramp.com / Unlicensed use prohibited." -P -r -overwrite_original -progress -k

I set Windows environment variable %PWP% that points to the folder where exiftool.exe is, to shorten the script.

While I'm royally confused about different file and metadata date and time stamps, where they are kept and what events can change them, I guessed that TimeDateOriginal would be the camera EXIF date stamp.  I decided against it and in favour of FileCreateDate as some images may be stripped of EXIF and the script will fail. 

I imagine the -if command could be used to check if TimeDateOriginal is there, but I don't know how to make -if to produce an alternative output (i.e. FileCreateDate) if the condition fails.

Perhaps there are some other date tricks that could be used to make my script better, but I need a EXIFTool Jedi for that...

Cheers!
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: mcjtom on January 04, 2020, 07:38:23 AM
While I still haven't solved my conditional copyright year dilemma, thanks to StarGeek I figured out a short way of writing copyright to EXIF, IPTC, and XMP in one go.  The -IPTC:Credit="..." is there to populate the IPTC as without it -MWG doesn't want to write there.

%PWP%\exiftool.exe -IPTC:Credit="Maciej Tomczak" -MWG:Creator="Maciej Tomczak" -d %Y "-MWG:Copyright<Copyright (c) $FileCreateDate Maciej Tomczak / www.phototramp.com / Unlicensed use prohibited." -P -r -overwrite_original -progress -k
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: Phil Harvey on January 04, 2020, 08:43:28 AM
I imagine the -if command could be used to check if TimeDateOriginal is there, but I don't know how to make -if to produce an alternative output (i.e. FileCreateDate) if the condition fails.

You don't use -if for this.  Instead, do this:

%PWP%\exiftool.exe -EXIF:Artist="Maciej Tomczak" -d %Y "-EXIF:Copyright<Copyright (c) $FileCreateDate Maciej Tomczak / www.phototramp.com / Unlicensed use prohibited." "-EXIF:Copyright<Copyright (c) $DateTimeOriginal Maciej Tomczak / www.phototramp.com / Unlicensed use prohibited." -P -r -overwrite_original -progress -k

The second assignment will overwrite the first if DateTimeOriginal exists.

- Phil
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: mcjtom on January 05, 2020, 07:56:33 AM
Great, thanks!

One more iteration: if I want to simplify the issue and just use DateTimeOriginal and, rather than looking for FileCreateDate, just skip the year in the copyright info if the EXIF date doesn't exist? 

The way I tried it before, no copyright tags are written if DateTimeOriginal is specified but missing.

Cheers!
Title: Re: Shortcuts for Windows Explorer 'Send To' right-click menu
Post by: mcjtom on January 05, 2020, 01:20:47 PM
I think I solved it with the -f option.  It prints "-" when the -DateTimeOriginal doesn't exist.  And the bonus is that my notice is still within 260 characters of Windows Shortcut Target limit, which simplifies things for me.

%PWP%\exiftool.exe -IPTC:Credit="Maciej Tomczak" -MWG:Creator="Maciej Tomczak" -f -d %Y "-MWG:Copyright<Copyright (c) $DateTimeOriginal Maciej Tomczak / www.phototramp.com / Unlicensed use prohibited." -P -r -overwrite_original -progress -k