test if folder exists using curl before making a new directory.

Hi,

I’m using the following code to create a folder using a curl shell script called from an applescript, which works perfectly:


on createTheFolder(webFolderName)
	do shell script "curl -Q 'MKD " & htmlPath & webFolderName & "' " & ftpInfo
end createTheFolder

where htmlPath is the path, webFolderName is the name for the new folder, and ftpInfo is the ftp login information in ftp://user:password@ftp.something.com:21 format.

I would like to check if the folder in webFolderName already exists before creating the folder though.

Anyone know a way to check for this?

Thanks
Kyle

Here is a list of ftp commands:

http://www.nsftools.com/tips/RawFTP.htm

Perhaps you could use “LIST” (obvious) or “CWD” (on error = doesn’t exist)

thanks - that worked for me. I put the command in a try statement which tests for that folder using the CWD command:


try
				do shell script "curl 'CWD " & passwdFilePath & webFolderName & "' " & ftpInfo
				do shell script "curl -Q 'MKD " & passwdFilePath & webFolderName & "' " & ftpInfo
				
on error
				display dialog "There's a problem with the name you entered.  Does that folder already exist online?" buttons "Ok" default button 1 with icon caution
end try