On MAC O.S., how to get the name of files that has been dropped onto apple script to boot JAR with the name of file as a argument to JAR

前端 未结 3 569
Happy的楠姐
Happy的楠姐 2020-12-21 12:50

In Script editor i have written a command to boot the JAR.

do shell script \"cd /Desktop/RunJar/; java -jar RunMyJar.jar\"

and Saved as

3条回答
  •  遥遥无期
    2020-12-21 13:00

    You can also easily modify my answer to a similar question:

    on open of theFiles -- Executed when files are dropped on the script
    
        set fileCount to (get count of items in theFiles)
    
        repeat with thisFile from 1 to fileCount
            set theFile to item thisFile of theFiles
            set theFileAlias to theFile as alias
    
            tell application "Finder"
                    set fileInfo to info for theFileAlias
                    set fileName to name of fileInfo
    
                    -- something to this effect, but now that you have the file name,
                    -- do what you will...
                    do shell script "cd /Desktop/RunJar/; java -jar " & fileName
    
            end tell
    
        end repeat
    
    end open
    

提交回复
热议问题