Choose from list, move to another folder

Hi, as part of a larger backup script i’ve been working on reading a folders subfolders, presenting that as a list with multiple selections allowed, and then moving those selections to another location.

I’ve got this part working as a do shell script call. However for the next part of the script to work, i need to wait until the shell command is completed, which in applescript is pretty tricky to do. So I’m thinking ideally I would use the Finder to do it. But i can’t seem to make it work, even though i suspect it’s a simple thing to do.

Below is the script i have so far. Does anyone know how to make it work via the Finder instead of a terminal command?

Thanks!


property colorSourceFolder : "Stuff:Color:Renders" as alias
property colorDestFolder : "Color/Renders"
property scriptCommand : ""

tell application "Finder"
	activate
	set localPath to container of (path to me) as string
	set localPosixPath to POSIX path of localPath
	--display dialog localPosixPath
	set colorFolders to name of folders of colorSourceFolder
	choose from list colorFolders with prompt "Please choose the project(s) you would like to mark for backup:" OK button name "Choose" with multiple selections allowed
	tell result
		if it is false then error number -128 -- cancel
		set selectedColorFolders to it
	end tell
end tell

(*
--this is the part I couldn't make work
if (count of selectedColorFolders) is greater than or equal to 1 then
	repeat with n in selectedColorFolders
		set thisColorItem to colorSourceFolder & n
		move thisColorItem to (localPath & colorDestFolder)
		
	end repeat
end if
*)

if (count of selectedColorFolders) is greater than or equal to 1 then
	repeat with n in selectedColorFolders
		set thisColorItem to colorSourceFolder & n
		display dialog thisColorItem as string
		set posixColorPath to POSIX path of (thisColorItem as string) as string
		set scriptCommand to scriptCommand & ("mv " & posixColorPath & " " & localPosixPath & colorDestFolder & "; ")
	end repeat
end if

tell application "Terminal"
	do shell script scriptCommand & "exit"
end tell


Hi,

there are some problems in your script, this should work


property colorSourceFolder : "Stuff:Color:Renders:"
property colorDestFolder : "Color:Renders:"

tell application "Finder"
	activate
	set localPath to container of (path to me)
	set colorFolders to name of folders of folder colorSourceFolder
	choose from list colorFolders with prompt "Please choose the project(s) you would like to mark for backup:" OK button name "Choose" with multiple selections allowed
	tell result
		if it is false then error number -128 -- cancel
		set selectedColorFolders to it
	end tell
end tell

set destinationFolder to ((localPath as text) & colorDestFolder)
repeat with aFolder in selectedColorFolders
	set thisColorItem to colorSourceFolder & aFolder
	tell application "Finder" to move folder thisColorItem to folder destinationFolder
end repeat