Last active
August 29, 2015 14:01
-
-
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
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
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