Your best friend for file transfer.

Automated Fetch Scripts Occasionally Saving Files in Root Directory Rather Than Subdirectory (6 posts)
- Started 11 years ago by Brad
- Latest reply 11 years ago from Jim Matthews
-
Brad Member
-
Jim Matthews Administrator
I would change the line
put into current folder item alias thecurrentfile text format Raw Data binary format Raw Data
to:
put into remote folder FTP_site item alias thecurrentfile text format Raw Data binary format Raw Data
That way you're explicitly indicating where the upload should go. You could also remove the "open remote item FTP-site" line, since you wouldn't need it anymore.
Does that help?
Thanks,
Jim Matthews
Fetch Softworks -
Brad Member
Jim,
I will try it out although I did try "remote folder" instead of "current folder" in an earlier version. The sporadic nature of the problem is what is perplexing. I'm still not convinced that the vendor's FTP server is not at fault, but unfortunately we're in a he said she said situation.
I was wondering if possible my use of selecting one item at a time could be causing an issue. Sometimes we are sending 50 to 100 of these 1 to 2k files. Is there an Applescript syntax for sending all items within a given folder?
Thanks
Brad -
Jim Matthews Administrator
The problem with using "current folder" is that if another transfer window comes to the front while the "open remote item" line is executing, you could upload to the wrong folder.
Yes, it is possible to upload multiple files with a single AppleScript command. I think you could replace the lines of your script between "set idle time to 60" and "return idle time" with:
set items_to_upload to {}
repeat with one_file_name in source_folder_list
set one_alias to alias (PBS_XML_Location & one_file_name)
set items_to_upload to items_to_upload & one_alias
end repeattell application "Fetch"
with timeout of 900 seconds
put into remote folder FTP_site item items_to_upload text format Raw Data binary format Raw Data
end timeout
end telltell application "Finder"
try
move items_to_upload to folder PBS_XML_Backup with replacing
end try
end tellThe first part compiles a list of aliases to the files you want to upload. Then that list, items_to_upload, can be passed to Fetch's put into command.
NOTE: You should test this code before putting it into production.
Thanks,
Jim Matthews
Fetch Softworks -
Brad Member
Jim,
Just wanted to let you know that using the remote folder command versus the current folder seems to have fixed my problem. Processing is looking very clean and the batch uploading script is working as expected.
Thanks again.
Brad
-
Jim Matthews Administrator
Glad to hear it!
Jim Matthews
Fetch Softworks
- Page 1
I'm using automated Fetch scripts to send less than 2k XML and Log files to an external company. For some reason, some of these files will be save in the root directory on the external company's server rather than saving in the designated sub-directory. There doesn't appear to be any rhyme or reason although I'm thinking that the various Fetch scripts I am currently using on this server (6) may be causing some kind of a conflict. I thought the problem might be on the external company's end, although they say they are not the problem (not surprising).
Any suggestions would be appreciated since I have another 10 scripts I'm planning on adding to this server.
Thanks
Brad
--
Here's one of the scripts I am using:
on idle
-- Variables
set PBS_XML_Location to "PBSTransfer:adtracking:" -- this includes the path to the storage area
--set TWIPaddress to "theserver.com"
set PBS_XML_Backup to "PBSTransfer:XML_backup:"
set FTP_site to "sftp://username:password@theserver.com/input-rst1rst/xml/"
set source_folder_list to list folder PBS_XML_Location without invisibles
set source_folder_count to count of source_folder_list
set idletime to 60
-- Script
set currentitem to 1
repeat source_folder_count times
set thecurrentfile to PBS_XML_Location & item currentitem of source_folder_list as string
try
tell application "Fetch"
activate
open remote item FTP_site
with timeout of 900 seconds
put into current folder item alias thecurrentfile text format Raw Data binary format Raw Data
end timeout
end tell
end try
--moves local file to backup folder
tell application "Finder"
activate
try
move alias thecurrentfile to folder PBS_XML_Backup with replacing
end try
end tell
set currentitem to currentitem + 1
end repeat
return idletime
end idle
Posted 11 years ago #