Shortcuts for Windows Explorer 'Send To' right-click menu

Started by mcjtom, January 02, 2020, 12:13:32 AM

Previous topic - Next topic

mcjtom

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!





mcjtom

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!

mcjtom

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...

StarGeek

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.

Quote from: mcjtom on January 02, 2020, 12:13:32 AMI'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' "

QuoteFor '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.

QuoteAlso, 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 for details) or use the MWG:Creator tag 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'],

Quote from: mcjtom on January 02, 2020, 01:56:40 AM
- 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 "...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 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.

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.
* 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).

Phil Harvey

StarGeek responded while I was composing my answer, but here is what I wrote anyway:

Quote from: mcjtom on January 02, 2020, 12:13:32 AM
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):

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


QuoteI'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.

QuoteFor '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.

QuoteI 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.

Quote from: mcjtom on January 02, 2020, 01:56:40 AM
- 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.

Quote from: 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...

The .bat file also gets around this problem.

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

mcjtom

Many thanks for all your detailed help!  Here are my SendTo shortcuts scripts that seem to work the way I wanted them to

Cheers!

StarGeek

One more hint.  Instead of
C:\Users\<yourusername>\AppData\Roaming\Microsoft\Windows\SendTo
you could use the %APPDATA% ENV variable
%APPDATA%\Microsoft\Windows\SendTo
* 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).

mcjtom

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!

mcjtom

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

mcjtom

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

Phil Harvey

Quote from: mcjtom on January 03, 2020, 03:52:27 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.

QuoteThere 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.

Quote from: 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?

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

Quote from: 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

Yes.

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

mcjtom

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!

Phil Harvey

Quote from: 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)?

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.  These particular tags are found in the Extra tags 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 for more information about deleting all metadata from a TIFF 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 ($).

StarGeek

Quote from: mcjtom on January 03, 2020, 03:52:27 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.
* 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).

mcjtom

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?