FTP upload Script a little off

Hey Guys,

Found this script to upload files from a folder. I added my info and ran it, but I’m getting a shell error, and I don’t know what it means.


set these_files to POSIX path of (path to movies folder) & "myfolder/"
set ftp_path to "/httpdocs/autouploads"
set ftp_name to "mylogin" -->(which I added)
set ftp_pw to "mypassword" -->(which I added)
set ftp_server to "[url=ftp://ftp.mysite.com]ftp.mysite.com[/url]" -->(which I added)

repeat with this_file in these_files
	set thisPOSIXfile to quoted form of POSIX path of these_files
	set shellscript to "curl -u " & ftp_name & ":" & ftp_pw & " -T " & thisPOSIXfile & " " & ¬
		ftp_server & ""
	do shell script shellscript
end repeat

got the following:

[i] % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed

0 0 0 0 0 0 0 0 --:–:-- --:–:-- --:–:-- 0
curl: (3) Uploading to a URL without a file name![/i]

the error message is quite clear.
You’re going to upload a file to an URL (ftp.mysite.com) but without specifying a filename.

You have to concatenate the URL ftp_server, ftp_path and the name of the file

I’m not too clear on shell script, but in looking at it, isn’t that what it’s doing after I set all the variables above?

the variable these_files is set to the MyFolder, which has all the files I want to upload. So when the the repeat command is implemented, shouldn’t the file name be the name of the file it’s grabbing from the folder?

you need something like this


set myFolder to ((path to movies folder as text) & "myfolder:")
set ftp_path to "/httpdocs/autouploads/"
set ftp_name to "mylogin" -->(which I added)
set ftp_pw to "mypassword" -->(which I added)
set ftp_server to "[url=ftp://ftp.mysite.com]ftp.mysite.com[/url]" -->(which I added)

tell application "Finder" to set these_files to files of folder myFolder
repeat with this_file in these_files
	set fileURL to quoted form of (ftp_server & ftp_path & name of (info for (this_file as alias)))
	set thisPOSIXfile to quoted form of POSIX path of (this_file as alias)
	set shellscript to "curl -u " & ftp_name & ":" & ftp_pw & " -T " & thisPOSIXfile & " " & fileURL
	do shell script shellscript
end repeat

That worked.

I see what you did now. I just didn’t realize you would need finder to define the files within the folder as a variable. I thought the shell command was reading myfolder, and repeating the shell command for every file within it.

Thanks for the clarification and your help.

the Finder is not necessary essentially, you can also use list folder or /bin/ls, but
the repeat loop needs a list of file paths, aliases or Finder file specifiers