FTP access with applescript studio

Hi, I had some experience with applescript and xcode but am fairly new to the game. I’m trying to put together a program that’ll browse and download files from an FTP site I have. I know there are plenty of programs like Fetch that do exactly this but I’m trying to make one that will only access this one FTP site with all passwords already in the program so that someone with no computer knowledge can just run the app, browse the files and download (it’s a photo archive).
The script for downloading specific files I think I have down but, and this might be the simplest thing in the world, I can’t find a way to show a list of available files so that they can be broswed through. Seems like it shouldn’t be too hard but can’t find a way, URL Access Scripting only seems to have upload and download.
A nudge in the right direction would be greatly appreciated.

Here’s some code I took from a ftp app I wrote a while back. It uses the “curl” shell command to fetch a directory listing in plain text, formats the text, and then parses it to get a list of the desired fields. It currently rips out the name, date, and permissions.

set ftpUsername to "joe_shmoe"
set ftpPassword to "123456"
set ftpDirectory to ("ftp://www.mysite.com/public_html/images/")
set ftpLoginInfo to ("-u " & ftpUsername & ":" & ftpPassword & " ") as string

set tmpCurlCommand to ("curl " & ftpLoginInfo & (quoted form of ftpDirectory))

(* Get the raw terminal results for the curl query *)
try
	set tmpCurlResults to do shell script tmpCurlCommand
on error errorMessage number errorNumber
	set tmpCurlResults to ""
end try

if tmpCurlResults is not "" then
	set theRecords to {}
	set tmpCurlResults to (tmpCurlResults as text)
	set tmpCount to count paragraphs of tmpCurlResults
	
	(* Get the name, date, permissions for each item record *)
	repeat with tmpIndex from 1 to (count paragraphs of tmpCurlResults)

		(* Use perl to strip out the spaces used for padding *)
		set thePerlScript to ("$theVariable="" & (contents of paragraph tmpIndex of tmpCurlResults) & "";
(@theList)=split(/ /, $theVariable);
@newList=();
foreach $listItem (@theList) {if ($listItem ne ""){push (@newList,$listItem)};};
print "@newList";")
		set perlOutput to do shell script ("perl  -e " & quoted form of thePerlScript)
		
		set oldDelimiter to AppleScript's text item delimiters
		set AppleScript's text item delimiters to " "
		set tmpRecord to text items of (perlOutput as string) as list
		set tmpName to (text item 9 of tmpRecord) as string
		set tmpDate to ((text item 6 of tmpRecord) & " " & (text item 7 of tmpRecord) & ", " & (text item 8 of tmpRecord)) as string
		set tmpPerm to (text item 1 of tmpRecord) as string
		set AppleScript's text item delimiters to oldDelimiter
		
		(* If it's not an invisible server file and it's not a directory, add it to the list *)
		if (character 1 of tmpName is not ".") and (character 1 of tmpPerm is not "d") then
			copy {tmpName, tmpDate, tmpPerm} to the end of theRecords
		end if
	end repeat
	
	return theRecords
else
	display dialog "Could not get directory contents!" with icon 2 buttons {"OK"}
end if

If successful, it returns the variable ‘theRecords’, which is a list of lists like this…

It ignores invisible server files (beginning with a “.”), but you’ll have to write the code to do any other checking you may need. If the directory only has images in it, this may be enough as it is. Then, just use the data from the lists and add it to your table view as you would from any other list of data.

Good luck,
j

Fantastic, thank you so much, there’s no way I’d have even got close to figuring that out.