Your best friend for file transfer.

get information about (4 posts)
- Started 10 years ago by JImBrandt
- Latest reply 10 years ago from Jim Matthews
-
JImBrandt Member
-
Jim Matthews Administrator
Hi,
Those are great questions! In particular, because the answer to question 2 changes the answer to question 1! So I'm going to answer them in order, and then circle back to question 1.
1) You don't need to use a second command to verify that an upload command succeeded. If it doesn't succeed your script will receive an error, so if you don't get an error you're all set. This is true of all Fetch AppleScript commands. But see below for an exception.
2) Yes, there is a way to start multiple uploads at the same time, by specifying an "immediate return" parameter of true. For example:
set transferRef to put into url "ftp://user:@hostname/path/" item POSIX file "/tmp/foo.txt" with immediate return
This command immediately returns a transfer reference (which we are stashing in a variable named transferRef), so your script can go on to do other things (including start other transfers).
To check if a transfer has completed, check its completed property, e.g.:
if completed of transferRef then display dialog "Transfer done!"
To check if a transfer failed, check its failed property:
if failed of transferRef then display dialog "Transfer failed!"
You can also check things like how many bytes have been transferred, how much time remains, etc. For details, look at the "transfer" class in the Fetch AppleScript dictionary.
1) Revisited: If you use the "immediately return" option your script will not get an error if the command fails. It will be your responsibility to check the "failed" property.
I hope this helps!
Jim Matthews
Fetch Softworks -
JImBrandt Member
Jim,
Thanks for the reply. Seems like that may be the way I go.
But, I'd also like to use the "get information about" command to check a few things also and can't seem to get the syntax correct.
Here's what I tried:
set FTP_Site to FTPType & "://" & StaUserName & ":" & StaUserPass & "@" & HostAddress
tell application "Fetch"
activate
open remote item FTP_Site
tell transfer window 1
set Stat to status
set ConnectedTo to current folder
end tell
### handle sites that don't auto connect to a specific directory
if Stat = "connected." then
if ConnectedTo ≠ UpLoadDir then
tell transfer window 1
set current folder to UploadDir
end tell
end if
set DestinationURL to url of transfer window 1
end if
set fileInfo to get information about file (DestinationURL & ThisFile)Here's the last few lines of the Events in the AS Editor:
get url of transfer window 1
--> "<ftp://creative:@ftp.cwmontgomery.com/%2Fftp/pub/creative/>"
get information about file "<ftp://creative:@ftp.cwmontgomery.com/%2Fftp/pub/creative/>AFH13IB3PTVH.mov"
--> error number -35
Result:
error "Fetch got an error: Disk some object wasn’t found." number -35Where am I going wrong?
Thanks,
Jim
-
Jim Matthews Administrator
Hi,
There are a couple problems:
1) The expression (DestinationURL & ThisFile) evaluates to:
<ftp://creative:@ftp.cwmontgomery.com/%2Fftp/pub/creative/>AFH13IB3PTVH.mov
which is incorrect because of the angle brackets (<>) that start and end DestinationURL
2) You ask for information about "file (DestinationURL & ThisFile)", but "file" only refers to files on your Mac, not to files on a server.
The syntax you want is:
set fileInfo to get information about remote file ThisFile of transfer window 1
This works because I've changed "file" to "remote file", which tells AppleScript that we aren't talking about a file on your Mac, and because I removed the reference to DestinationURL, which was unnecessary since Fetch will look for ThisFile in transfer window 1.
One more comment: the "of transfer window 1" is optional. If you leave it out Fetch will implicitly look in the frontmost transfer window.
Thanks,
Jim Matthews
Fetch Softworks
- Page 1
I'm writing a script that uses Fetch to upload up to 24 files to 24 different locations (with many more in the future).
1) Can I use the "get information about" command in an Applescript to verify that the uploaded file made it to the FTP site? If so, exactly what would the syntax of that command be? My problem here is that the owner of the FTP site is moving the file out of the directory shortly after it is uploaded so I need to do this check as soon as the upload is complete.
2) Is there a way to start multiple uploads at the same time to different locations from an Applescript? I really would like to transfer more than one file at a time if it's easy to do. But I need a way to a) track which ones are complete and b) handle the errors if they fail.
I didn't see any similar types of situations in the example scripts. Are there other examples?
TIA,
Jim
Posted 10 years ago #