Skip to content

Instantly share code, notes, and snippets.

@lsfalimis
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lsfalimis/a52a6de6c7471dfb9e66 to your computer and use it in GitHub Desktop.
Save lsfalimis/a52a6de6c7471dfb9e66 to your computer and use it in GitHub Desktop.
For beginner, http://lsfalimis.github.io/applescript-python-passing-filename/. Get file name, strip out extension, divide file name, merge or concatenate a list, get and pass UNIX path, pass multiple parameters or arguments to a python script in a shell script
tell application "Finder"
set theName to name of (theFile as alias)
set AppleScript's text item delimiters to "."
if number of text items of theName > 1 then
set theName to text items 1 thru -2 of theName
end if
set theItems to ""
repeat with i from 1 to count of theName
set theItems to theItems & "\"" & ((item i of theName) as text) & "\"" & ","
end repeat
set theItems to text 1 thru -2 of theItems
set thePath to POSIX path of theFile
do shell script "python /PATH/TO/THE/PYTHON/SCRIPT" & theItems & " " & quoted form of thePath
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment