Skip to content

Instantly share code, notes, and snippets.

@bvdputte
Created March 1, 2013 07:23
Show Gist options
  • Select an option

  • Save bvdputte/5063027 to your computer and use it in GitHub Desktop.

Select an option

Save bvdputte/5063027 to your computer and use it in GitHub Desktop.
rename file(s) naar metadata title via applescript
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