MacOS – How to remove metadata from image files using AppleScript

applescriptautomatormacosscript

I am using Catalina. I want to create an application using Applescript which which will remove metadata from dropped image files (onto its icon) using the unix utility exiftool.

I tried the following application in Automator but the AppleScript doesn't work (doesn't remove the metadata):

on open myFiles
    set bash_path_file to the POSIX path of myFiles
    do shell script "/usr/local/bin/exiftool -all= " & quoted form of bash_path_file
end open

I've researched many applescripts using google search and over here but none seem to work. So I'm doing something wrong. Any help would be appreciated.

Best Answer

To make an ApplesScript droplet app, save the following example AppleScript code in Script Editor as an application:

on open droppedItems
    repeat with droppedItem in droppedItems
        do shell script "/usr/local/bin/exiftool -all= " & ¬
            quoted form of POSIX path of droppedItem
    end repeat
end open

Now drag and drop the target file(s) onto the app's icon to process the file(s).


Note: The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors.