How can I accomplish this FTP task?

We want to upload a file directory tree (a website) to an FTP site, but 3 of the subdirectories contain a large number of image files that change very infrequently, so we want to leave those out. We also want to delete everything (except those 3 subdirectories) before uploading, in keeping with good deployment practices. In sum, we want to upload the files in the root directory, plus all subdirectories except 3 of them, deleting first wherever we upload.

Seems simple enough, but I can't seem to make that happen.

I learned from another post how to delete all the files in a directory without recursively deleting all subdirectories (thank you Angus). That takes care of the root directory. My plan for deleting all the subdirectories except 3 was to perform an FTP List Directory, saving the results to a variable, and then issue an FTP delete directory inside a list iterator, checking the name of the directory inside the loop to exclude the 3 image directories mentioned above.

The problem is the FTP list directory brings back just the files if you put "*.* in the file spec, but it brings back BOTH files and directories if you leave the file spec blank, even though a label on the dialog box states that leaving the file spec blank will bring back ONLY directories. Since I have no way of distinguishing between files and directories, and no way to list just directories - I'm stuck.

What am I doing wrong? Or is there another way to make this happen? I'm flexible on the approach, except we must (1) exclude the 3 image directories and (2) we must delete existing FTP data first; using the upload-changed-files-only approach is not acceptable.

Thanks,

BillyB

Hi Bill,

Thanks for posting. You should be able to structure a build something along these lines:

FTP List Directory
List Iterator (files and directories)
  Delete Files [ %item% ] (enable "Ignore Failure" on this action)
  If Prev Action Failed
    If [ %item% ] not in CSV List [ dontdeleteme, dontdeletemeeither ]
      Delete Directory [ %item% ]

This should give you the gist, but let me know if you'd like to see this as a sample project.

 

it brings back BOTH files and directories if you leave the file spec blank, even though a label on the dialog box states that leaving the file spec blank will bring back ONLY directories.

Unfortunately FTP servers have a tendency to vary a little bit in implementation. My guess is that whatever server you are connecting to is showing this behaviour.

Regards,

Angus

Ah. I see … delete as a file, then if you had an error it’s a directory. Shoulda thought of that. Thanks, I’ll try that.