-- Add -a in the arguments to keep the current selection of the front most window of the Finder selected while dealing with args of the command line -- BUGS -- In column mode, if only folders are selected, it doesn't work as expected -- The selection is only the last folder of the window. -- Works fine in other view mode -- If you do know how to fix this, please help on run argv set toselectList to {} set addtocurrentselection to false -- Parse the arguments, and add them to the list toSelectList repeat with thearg in argv -- Get the current directory from where the script is called if thearg begins with "Current_path:" then set currentdirectory to (text 13 thru (length of thearg) of thearg) -- 13 is the length of the string "Current_path:" else if thearg as string is equal to "-a" then set addtocurrentselection to true else set thecompletepath to "" set theargPOSIX to POSIX file thearg -- Try to be sure the file exists try tell application "Finder" the file theargPOSIX exists set thecompletepath to thearg end tell on error -- The file didn't exist, retry by suffixing it with the current directory set trypath to currentdirectory & "/" & thearg set trypathPOSIX to POSIX file trypath try tell application "Finder" the file trypathPOSIX exists set thecompletepath to trypath end tell end try end try -- If the file was found, add it to the list toselectList if thecompletepath is not "" then set end of toselectList to POSIX file thecompletepath end if end repeat tell application "Finder" activate if addtocurrentselection then -- Get the current selection set selectionList to {} & selection as list -- Be sure the selection isn't empty set selectedCount to count items in selectionList if selectedCount > 0 then set end of toselectList to selectionList end if end if -- Finally, select the files in the Finder (select every item of toselectList) end tell end run