Is there a way to be able to choose files and folders at the same time?
I am wanting a user to be able to select files and folders at the same time to be copied to a server.
any help is appreciated!
Thanks,
Scott
Is there a way to be able to choose files and folders at the same time?
I am wanting a user to be able to select files and folders at the same time to be copied to a server.
any help is appreciated!
Thanks,
Scott
Hello.
I don’t think so, but I believe you can use the navchoose object from Satimage.osax.
You can just install the osax which correlates to your operating system to make it work first, then install the suitable version at your users machine. It is really easy, it is just to download the osax and drop it into the ScriptingAdditions folder. You have to inform the user that you are using it, and that Satimage is the producer of it, with the address to Satimages hompage visible somewhere. You should find that page and read it your self.
Edit: I now recall that you as a matter of fact need to download the whole free version of Smile to get hold of the Satimage.osax unless I missed a page with osax’s only. Sorry.
Best Regards
McUsr
Not if you use the standard “Choose” dialog box. However, you can get multiple selections from a “Choose from list” dialog box. So let’s say you know what folder the user is going to choose their files from, in my example it is the desktop, then you can do something like this…
set theFolder to (path to desktop folder) as text
tell application "Finder"
set theItems to items of folder theFolder
set theNames to {}
repeat with anItem in theItems
set end of theNames to name of anItem
end repeat
end tell
choose from list theNames with prompt "Pick the items you want to copy from:" & return & theFolder OK button name "Copy" cancel button name "Quit" with multiple selections allowed
tell result
if it is false then error number -128 -- cancel
set theChoices to it
end tell
if (count of theChoices) is greater than or equal to 1 then
repeat with aChoice in theChoices
set thisItem to theFolder & aChoice
-- do something with thisItem
end repeat
end if
Hello there.
I liked Hank’s Idea, didn’t really think of that, although I have done so with windows lists before.
I fancied the list would look a whole lot better when showing the posix paths of the files, so I elaborated a little on Hanks solution. I put a dot in front of each directory entry to signal that it was local to the chosen path.
There aren’t really any other way of doing this with pure AppleScript without any Scripting Additions.
property LF : (run script "\"\\n\"") as Unicode text -- Nigel Garvey
property theNames : {}
-- Parts © McUsr 2010 and put in the Public Domain. You may not expose this code elsewhere than at MacScripter.net
set astid to AppleScript's text item delimiters
set theFolder to (choose folder) as unicode text
tell application "Finder"
set theNames to every item of entire contents of folder theFolder as alias list
end tell
set AppleScript's text item delimiters to LF
set theNames to items 2 thru -1 of my theNames as Unicode text -- every text item if there is no .DS_STORE file
set AppleScript's text item delimiters to Unicode text 1 thru -2 of theFolder
set theNames to every text item of my theNames
set AppleScript's text item delimiters to ""
set theNames to theNames as Unicode text
set AppleScript's text item delimiters to ":"
set theNames to every text item of my theNames
set AppleScript's text item delimiters to "/"
set theNames to theNames as Unicode text
set theNames to do shell script "echo " & quoted form of theNames & "| /usr/bin/sed 's/^/\\./g'"
set AppleScript's text item delimiters to return
set theNames to every text item of my theNames
-- end of McUsr's copyrights :-)
choose from list theNames default items item 1 of my theNames with prompt "Pick the items you want to copy from:" & return & POSIX path of theFolder as text OK button name "Copy" cancel button name "Quit" with multiple selections allowed
tell result
if it is false then error number -128 -- cancel
set theChoices to it
end tell
if (count of theChoices) is greater than or equal to 1 then
repeat with aChoice in theChoices
set thisItem to theFolder & aChoice
-- do something with thisItem
end repeat
end if
set AppleScript's text item delimiters to astid
Edit: I wasn’t totally finished playing with it when I uploaded it the first time, I have optimized it for speed,
and made it backwards compatible with Tiger.