1

This question already has an answer here:

I want to create an Automator Service that will run an xattr Terminal command on a single or batch of files.

I can do the operation in Terminal (kinda), but I didn't understand how to apply that to Automator.

Basically I was trying to remove Where From extended attributes from an flv or mp4 file. In terminal I'd simply type:

xattr -d com.apple.metadata:kMDItemWhereFroms /Path/To/File

That threw an error, but it still worked.

I'm running macOS 10.11.6, El Cap.


I finally figured it out. It appears I didn't need to be as selective with the xattr command, since I just want to clear all the extended attributes. Here's an image of what appears to work:

Automator Service That Works

I still don't entirely understand the actual Shell Script language. I learned from reading a lot of other posts that unlike Terminal, you have to tell the shell script where xattr (the tool) is.

/usr/bin/xattr

I assume that "$f" is the file(s) that you select in the Finder.

I continue to be confused by the difference between "Get Selected Finder Items" & Get Specified Finder Items." They both seem to pass whatever you choose in the Finder through. I chose the 1st option and it worked.

Apologies if this all seems elementary to you guys, I have zero experience writing scripts. I just usually cut and paste someone else's work, and 9 times out of 10 that's done the job. Just couldn't find this particular explanation anywhere. Hopefully it will help someone else.

marked as duplicate by Graham Miln, Allan, nohillside Mar 3 '17 at 12:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Here's explanation how to run command on files using Automator: apple.stackexchange.com/questions/232205/… – Mateusz Szlosek Mar 3 '17 at 9:12
  • Thanks for the help. I had seen the many references to how to create an Automator Service. Creating the service wasn't so much the issue, as how to translate a known Terminal command into something that works in Automator. I was having a hard time understanding how to apply my situation to all the other questions out there. I found a solution, though I can't say I entirely understand what I did. I had hoped someone would help explain the steps so I could actually learn something. Thanks anyway. I'll see if I can post my solution to the original question, assuming that's acceptable here. – Ballou Mar 5 '17 at 5:50

Browse other questions tagged .