moving selected file from one folder to another

I am trying to move a selectd file from one folder to another through the use of a list. I have setup two folders on my desktop titled test1 and test2. I can select from the list but it will not move the file from test1 to test2. In addition, I have used sections of other’s scripts and referenced an Applescript book. Can anyone help as I am not understanding what it takes to move the selected file. Thanks.

set the_folder to (path to home folder as Unicode text) & “desktop:test1”
set the_destinationfiles to “OSXJ:users:osxj:desktop:Print Test2”

tell application “Finder” to set the_list to name of files in folder the_folder
set pickfiles to (choose from list the_list with prompt “Choose Which File to add:” OK button name “Choose” cancel button name “Cancel” default items {the_list’s item 1} with empty selection allowed and multiple selections allowed)
if pickfiles = false then
else
repeat with i from 1 to (count pickfiles)
set (pickfiles’s item i) to (the_folder & (pickfiles’s item i) & return)
end repeat

if pickfiles = true then
	tell application "Finder"
		try
			duplicate i to "OSXJ:users:osxj:desktop:Test2" with replacing
		end try
		
	end tell
end if

end if

auberge2,

The problem is that the list, “pickfiles”, is a list of names only (because the_list is a list of names) and not a reference to the files needed. You have to loop through your actual files and compare each name with the names that are in “pickfiles”. I didn’t test this script, so let me know if it doesn’t work.

set the_folder to (path to home folder as Unicode text) & "desktop:test1"
set the_destinationfiles to "OSXJ:users:osxj:desktop:Print Test2"


tell application "Finder" to set the_list to name of files in folder the_folder
set pickfiles to (choose from list the_list with prompt "Choose Which File to add:" OK button name "Choose" cancel button name "Cancel" default items {the_list's item 1} with empty selection allowed and multiple selections allowed)
if pickfiles = false then
else
    repeat with i from 1 to (count the_folder)
        repeat with k in pickfiles
        if k is name of item i of the_folder then
            duplicate i to "OSXJ:users:osxj:desktop:Test2" with replacing
        end if 
    end repeat
end if

PreTech

For reasons I couldn’t sort out, I could only get Jacques’ solution to work in this form:

set fStart to (path to desktop as text) & "Start:" as alias
set fFinish to (path to desktop as text) & "Finish:" as alias

tell application "Finder" to set myList to name of files in folder fStart
set pick to (choose from list myList with empty selection allowed and multiple selections allowed)
if pick is not false and pick is not {} then
	repeat with k from 1 to count pick
		set item k of pick to ("" & fStart & item k of pick) as alias
	end repeat
	tell application "Finder" to duplicate pick to fFinish with replacing
end if

Hi guys. It should be possible to do this without a repeat loop, using only Finder references and a conditional filter. The fact that the folders (“test1” & “test2”) are on the desktop also tends to simplify matters:

tell application "Finder"
	tell folder "test1"
		set l to choose from list (get name of files) with multiple selections allowed
		if l is false then error number -128
		set l to files whose name is in l
	end tell
	duplicate l to folder "test2" with replacing
end tell

Morning all

Fisrt of all thank you for your help. I did get Jacques script to work and it works great. Thanks again.

Browser: Safari 412
Operating System: Mac OS X (10.4)