- macOS/Mac OS X (tested only on El Capitan, but should work on Sierra and older versions)
- Xcode Command Line Tools / Xcode
- Homebrew (http://brew.sh/)
- Tag (via Homebrew)
- ExifTool (via Homebrew)
- For installing Xcode and Command Line Tools. Please see: http://railsapps.github.io/xcode-command-line-tools.html
- Open up your Terminal.app (or iTerm.app)
- Follow the instructions at http://brew.sh to install Homebrew in a snap.
- Install ExifTool by copy paste:
brew install exiftool
. - Install Tag by copy paste:
brew install tag
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install exiftool
brew install tag
- Open up Automator.app located in your Applications folder.
- Choose ”Service” in the dialog sheet when creating a new document.
- In the
Services receives selected:
menu at the top of the ”Canvas” on the right, change tofiles and folders
and ”in” toFinder.app
- In the sidebar to the left, search for
Set Spotlight Comments for Finder Items
- Drag the
Set Spotlight Comments for Finder Item
action to the ”canvas” on the right side. - In the text field for the
Set Spotlight Comments for Finder Item
action, add one single space (for some reason, if left empty, it will not work for what we are doing). - In the sidebar to the left, search for
Run Shell Script
- Drag the
Run Shell Script
action to the ”canvas” on the right side. - At the right in the
Run Shell Script
action, change thePass input
fromto stdin
toas arguments
- Copy Paste this into the action text box (remove existing code in the text box, and change PATH to /usr/local/bin/exiftool if you want):
PATH=/usr/local/bin:/bin export PATH
for f in "$@"
do
exiftool -overwrite_original -all= "$f"; tag -r "*" "$f"
done
Save the Service into /Users/yourusername/Library/Services
. Test it by selcting a file with metadata (Finder Tags, Finder Labels, Camera Metadata, GPS Data, Spotlight Comments and so on) in the Finder and Right-Click
and go to end at the Context menu labeled ”Services” and look for the name you gave your Service. If everything works alright,
all Metadata stripped.
Line 1: PATH=/usr/local/bin:/bin export PATH
Tells where to look for the exiftool
and tag
tools.
This may not be necessary depending to your enviroment settings.
Line 4: exiftool -overwrite_original -all= "$f";
Removes all Metadata for Exif and so on and overwrites the original file (be careful!).
The $f
is telling the command what file(s) it's working with.
The ;
at the end indicates when the command is finished, go ahead and jump to the next command.
Line 4: tag -r "*" "$f"
The tag -r
removes all Finder Tags and Labels.
The "*" "$f"
means all file types and the file(s) choosen.
Here we use xattr instead of the ”Tag” tool.
- Open up Automator.app located in your Applications folder.
- Choose ”Service” in the dialog sheet when creating a new document.
- In the
Services receives selected:
menu at the top of the ”Canvas” on the right, change tofiles and folders
and ”in” toFinder.app
- In the sidebar to the left, search for
Set Spotlight Comments for Finder Items
- Drag the
Set Spotlight Comments for Finder Item
action to the ”canvas” on the right side. - In the text field for the
Set Spotlight Comments for Finder Item
action, add one single space (for some reason, if left empty, it will not work for what we are doing). - In the sidebar to the left, search for
Run Shell Script
- Drag the
Run Shell Script
action to the ”canvas” on the right side. - At the right in the
Run Shell Script
action, change thePass input
fromto stdin
toas arguments
- Copy Paste this into the action text box (remove existing code in the text box, and change PATH if necessary):
for f in "$@"
do
/usr/local/bin/exiftool -overwrite_original -all= "$f";
xattr -d com.apple.metadata:_kMDItemUserTags "$f" 2> /dev/null;
xattr -d com.apple.metadata:kMDItemWhereFroms "$f" 2> /dev/null;
xattr -d com.apple.metadata:kMDItemDownloadedDate "$f" 2> /dev/null;
xattr -d com.apple.FinderInfo "$f" 2> /dev/null
done
Line 3: /usr/local/bin/exiftool -overwrite_original -all= "$f"
As in the first script it tells where to look for the exiftool
tool. Difference here is we are using the path to the binary
instead of using a general path.
This may not be necessary depending to your enviroment settings.
Line 4-6:
2> /dev/null
when an extended attribute like com.apple.metadata:kMDItemWhereFroms
is not present, it will stop the
Workflow and outputs a warning message. In the Terminal it will simply output ”No such xattr: com.apple.metadata:kMDItemWhereFroms
.
But in a Automator Service, it stops the Workflow, so we direct the error message into a black hole which is: 2> /dev/null
so the service can continue regardless.
I have been looking for a way to manipulate Spotlight Comments via the CLI, but the ones i found have failed. Using xattr -d com.apple.metadata:kMDItemFinderComment
seems to removes the comment from Spotlight,
but not the Finder Info Comment window unless you remove .DS_store, which also removes the metadata for all files in that directory if i understand it correctly.
Please let me know if you know a way.
If you find errors or better ways to do things, let me know if there is better practices i could use and so on!
Getting creative with naming the Service. You could use a Emoji or Unicode symbol in the beginning of the file name. While it's not best practice in the *
-nix or Windows world (or anywhere else), this is Mac only and for your personal use, also it will not give you any kind of problems (if you send it to someone, do zip
the file first!). Example: EMOJI - Vector | SVG 2 EPS
. Makes it easier to locate in the sometimes crowded ”Services” Contextual menu.
Example (from my SVG2PNG Service):
To manipulate comments, I use a service written on an Applescript. Here is the code: