AppleScript Loop Over Multiple Folder

The Cyberduck forums have moved to Google Groups, this forum is read only.
tresmont
Harmless
Posts: 1
Joined: Wed Apr 08, 2009 2:25 pm

AppleScript Loop Over Multiple Folder

Postby tresmont » Wed Apr 08, 2009 2:32 pm

Hi All,

I have a series of nested folders on an FTP that I need to loop over and download specific files from. I've modified the download example, and it works for the first folder. The script then goes into an endless loop in the first folder downloading the same files over and over. How do I get the inner loop to finish then move to the next folder? Thanks for your help.

code:

set theYear to "2003"
set downloadFolder to "/Volumes/ELMPassport/modis/aqua/"
tell application "Cyberduck"
set theBrowser to (make new browser)
with timeout of 300 seconds
tell (theBrowser)
set the encoding to "UTF-8"
set show hidden to false
connect to "ladssci.nascom.nasa.gov" with protocol "ftp" as user "xxxxxx" with password "xxxxxx" with initial folder "/allData/5/MYD13Q1"
change folder to theYear
set theFolders to (browse folder (get working folder))
repeat with aFolder in theFolders
change folder to aFolder
set theFiles to (browse folder (get working folder))
repeat with aFile in theFiles
set tile to get text 18 thru 23 of aFile
if tile is "h21v04" then
download item aFile to downloadFolder & theYear
else if tile is "h22v04" then
download item aFile to downloadFolder & theYear
else if tile is "h22v05" then
download item aFile to downloadFolder & theYear
else if tile is "h23v04" then
download item aFile to downloadFolder & theYear
else if tile is "h23v05" then
download item aFile to downloadFolder & theYear
else if tile is "h24v04" then
download item aFile to downloadFolder & theYear
end if
end repeat
end repeat
disconnect
end tell
end timeout
end tell

Return to “Cyberduck”

Who is online

Users browsing this forum: No registered users