# How can I accomplish this FTP task?

**URL:** https://www.finalbuilder.com/forums/t/how-can-i-accomplish-this-ftp-task/879
**Category:** Discussion
**Created:** [June 19, 2008, 5:55am UTC](https://www.finalbuilder.com/forums/t/how-can-i-accomplish-this-ftp-task/879 "2008-06-19T05:55:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![wgbarnum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/w/779978/32.png) [@wgbarnum](https://www.finalbuilder.com/forums/u/wgbarnum)
#### Post date: [June 19, 2008, 5:55am UTC](https://www.finalbuilder.com/forums/t/how-can-i-accomplish-this-ftp-task/879/1 "2008-06-19T05:55:54Z")

</div>

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&nbsp;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&nbsp;(thank you Angus). That takes care of the root directory.&nbsp;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

---

<div class="post-metadata">

### Author: ![angus](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/a/b3f665/32.png) [@angus](https://www.finalbuilder.com/forums/u/angus)
#### Post date: [June 20, 2008, 2:11am UTC](https://www.finalbuilder.com/forums/t/how-can-i-accomplish-this-ftp-task/879/2 "2008-06-20T02:11:32Z")

</div>

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)   
&nbsp;&nbsp;Delete Files [%item%] (enable "Ignore Failure" on this action)   
&nbsp;&nbsp;If Prev Action Failed   
&nbsp;&nbsp;&nbsp;&nbsp;If [%item%] not in CSV List [dontdeleteme, dontdeletemeeither]   
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Delete Directory [%item%]   
  
This should give you the gist, but let me know if you'd like to see this as a sample project.

&nbsp;

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

---

<div class="post-metadata">

### Author: ![wgbarnum](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/w/779978/32.png) [@wgbarnum](https://www.finalbuilder.com/forums/u/wgbarnum)
#### Post date: [June 20, 2008, 7:41am UTC](https://www.finalbuilder.com/forums/t/how-can-i-accomplish-this-ftp-task/879/3 "2008-06-20T07:41:12Z")

</div>

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.
