Created
March 1, 2013 07:23
-
-
Save bvdputte/5063027 to your computer and use it in GitHub Desktop.
rename file(s) naar metadata title via applescript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on run {input, parameters} | |
| set thefile to input | |
| try | |
| tell application "Finder" | |
| repeat with thefile in input | |
| -- create variable with path from file for shell command | |
| set tPath to quoted form of (POSIX path of thefile) | |
| -- extract the value for the metadata tag | |
| set command to "mdls -name kMDItemTitle " & tPath | |
| set output to do shell script command | |
| -- als metadata title ingevuld is -> hernoem file naar metadata title | |
| if output is not equal to "kMDItemTitle = (null)" then | |
| set imgtitle to (characters 17 through -2 of output) as text | |
| set tExtension to the name extension of the thefile | |
| set the name of file thefile to imgtitle & "." & tExtension | |
| -- display dialog imgtitle | |
| end if | |
| end repeat | |
| end tell | |
| on error error_message | |
| display dialog error_message buttons {"Cancel"} default button 1 | |
| end try | |
| end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment