copying files from 1 location to another over IP

I am trying to make an AS which allows us to first select the files (browse) and
second to copy those files to 1 of three different folders on another computer.
I really don’t know where to start.
I case I was not clear enough:

  1. select files
    2.OK
  2. select location A, B or C (on which A,B and C are folder on another computer)
  3. OK

Is there anybody who can help me out plse?

Kris

Model: G5 and X-Serve
Browser: Safari
Operating System: Mac OS X (10.4)

hi kge,

here is a start:

set myFile to choose file with multiple selections allowed

although you may not want invisibles (can’t tell from your post):

set myFile to choose file with multiple selections allowed without invisibles

next you need to decide how to connect to the other machine. you’ll need to provide more info if you want some help with that. examples of connection protocols are:

  1. smb
  2. afp
  3. ftp

and there are others. if you can’t decide, you may want to post some more particulars about the machine you are trying to send to, and how much control you have over it (to set up services).

EDITED to take out http. probably not relevant here. plus i can’t spell.

First of all many thanks for your reply on my post here…

I don’t understand what you mean, sorry. But I am not a real AS pro you know, just a newbie.

If I understood well:

set myFile to choose file with multiple selections allowed without invisibles

This I need to select my files (which can be located in any particular folder)
Then I need to choose an IP (we use SMB) e.g. smb://192.1.8.150/receivefolder1
Where receivefolder1 is 1 of the 3 folder we have to choose to copy the selected files in.

Is this correct?

Kris

Model: G5 and X-Serve
Browser: Safari
Operating System: Mac OS X (10.4)

I deleted your double post from the other forum.

hi KGE,

ok, so you want to use SMB, that’s a good start. here is a good way to ‘mount’ the SMB share with a check to see if it’s already mounted:


tell application "Finder"
	if not (exists "recievefolder1") then
		mount volume "smb://192.1.8.50/receivefolder1" as user name "USER" with password "PASS"
	end if
end tell

which i got from here:

http://bbs.applescript.net/viewtopic.php?id=12159

you can use a display dialog to ask the user what share they need and use an if statement to get the button they pick. hope that helps.

How can we than choose which files to drop on which location without drag and drop?
Or can this be done?

regards

Kris

hi kge,

i’m not sure i follow. do you want to pick the files and then tell the AppleScript to put different ones in different files? my thought was that you would choose the files, pick the destination and send them there. then you’d run the script again if you wanted to send more files to another location.

let me know if i am misunderstanding.

also, post what you’ve written so far & i’ll see if i can help you down the right path.

EDITED to add the last sentence. plus i can’t spell.

actually, I have to admit my script looks sh**, but in order to explain a bit more about the script I like to create, hereby the trial :slight_smile:


tell application "Finder"
	set theItem to (choose file with prompt "Choose a file that you need to copy") as string
--the operator now browses in his computer or on the network and selects the right file(s)
--next step is that the selected files need to be copied to one of 3 folders on another computer so
--the operator has to have the ability to choose 1 or the next 3 locations. I prefer that they just have to click a button (A for location A, 'B' for location B,.. where the location is then the mounted volume)
copy selection to
button 'A' = mount volume "smb:/ip adress server/volumenameA" as user name "username" with password "password"
button 'B' = mount volume "smb:/ip adress server/volumenameB" as user name "username" with password "password"
button 'C' = mount volume "smb:/ip adress server/volumenameC" as user name "username" with password "password"

--when the operator clicks on e.g. button 'A', all selected files are copied in the background from location x to location 'A'.

end tell

Hope this helps?

regards,

Kris

hi kge,

yes, that does help. here is pretty much what i’d do. you’ll have to fill out the particulars and you may need to tweak it a bit. if you have questions, don’t hesitate:


--since our volume names are constant, let's store them in properties:

property Dest1 : "volumenameA"
property Dest2 : "volumenameB"
property Dest3 : "volumenameC"

tell application "Finder"
	set theItem to (choose file with prompt "Choose a file that you need to copy") as string
	--the operator now browses in his computer or on the network and selects the right file(s)
	--next step is that the selected files need to be copied to one of 3 folders on another computer so
	--the operator has to have the ability to choose 1 or the next 3 locations. I prefer that they just have to click a button (A for location A, 'B' for location B,.. where the location is then the mounted volume)
	
	set myDestination to button returned of (display dialog "What share would you like to send them to?" buttons {"volumenameA", "volumenameB", "volumenameC"} default button "volumenameA")
	
	if (myDestination is Dest1) then
		mount volume "smb:/ip adress server/volumenameA" as user name "username" with password "password"
	else if (myDestination is Dest2) then
		mount volume "smb:/ip adress server/volumenameB" as user name "username" with password "password"
	else if (myDestination is Dest3) then
		mount volume "smb:/ip adress server/volumenameC" as user name "username" with password "password"
	end if
	--copy selection to
	--button 'A' = mount volume "smb:/ip adress server/volumenameA" as user name "username" with password "password"
	--button 'B' = mount volume "smb:/ip adress server/volumenameB" as user name "username" with password "password"
	--button 'C' = mount volume "smb:/ip adress server/volumenameC" as user name "username" with password "password"
	
	--when the operator clicks on e.g. button 'A', all selected files are copied in the background from location x to location 'A'.
	
end tell

NOTE: we could use a function in there, but i want to make this as ‘easy’ as possible.

hi kge,

here’s some more to chew on:



--since our volume names are constant, let's store them in properties:

property Dest1 : "volumenameA"
property Dest2 : "volumenameB"
property Dest3 : "volumenameC"

tell application "Finder"
	set theItem to (choose file with prompt "Choose a file that you need to copy") as string
	--the operator now browses in his computer or on the network and selects the right file(s)
	--next step is that the selected files need to be copied to one of 3 folders on another computer so
	--the operator has to have the ability to choose 1 or the next 3 locations. I prefer that they just have to click a button (A for location A, 'B' for location B,.. where the location is then the mounted volume)
	
	set myDestination to button returned of (display dialog "What share would you like to send them to?" buttons {"volumenameA", "volumenameB", "volumenameC"} default button "volumenameA")
	
	if (myDestination is Dest1) then
		if not (exists Dest1) then
			mount volume "smb:/ip adress server/volumenameA" as user name "username" with password "password"
		end if
		copy theItem to disk Dest1
		--unmount disk Dest1
	else if (myDestination is Dest2) then
		if not (exists Dest2) then
			mount volume "smb:/ip adress server/volumenameB" as user name "username" with password "password"
		end if
		copy theItem to disk Dest2
		--unmount disk Dest2
	else if (myDestination is Dest3) then
		if not (exists Dest3) then
			mount volume "smb:/ip adress server/volumenameC" as user name "username" with password "password"
		end if
		copy theItem to disk Dest3
		--unmount disk Dest3
	end if
	
	
end tell

now you’ve got some copy functionality in there. if you want to ‘move’ the file you can change that. also, do you ‘unmount’ your share after copying files to it?