Delete files on FTP Server

Hi all,
I need some ideas on a possible solution please

I've got some xml files hosted on a shared server by a well known ISP

I'm trying to delete all xml files within a specific folder using a FTP Dos script since I have to do it very often (clear out old before writing new)

Tried the following:
del *.xml = Getting 550 Invalid filename error
del *.* = Getting 550 Invalid fielname error
rmdir myfolder = Getting 550 Folder not empty (if I try it from one cd level up)

So I called the ISP and they suggested
rm -rf *.xml
But it only works on their side since they have root access and I don't

Next idea might be to loop through the folder and deleting one file at a time with del filename.xml command since doing them specifically by actual filename does work via the dos script.
But I'm not sure how to loop through it using a ftp dos script? Also think the method will be slow.

Any other ideas or special switches I could use?

PS: I don't mind too much deleting and re-creating the entire folder

Thanks
Pierre KAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
Take a look at the 'glob' command from here: http://www.nsftools.com/tips/MSFTP.htm

Do you have SSH access?  'rm -rf *.xml' is a shell command, not an FTP command.
Dave BaldwinFixer of ProblemsCommented:
I don't know why you are using a command FTP client.  CoreFTP http://www.coreftp.com/ has a box to select only certain files where you can put in '*.xml' and Filezilla https://filezilla-project.org/ lets you search for files with a wildcard and then select them for deletion or download.
Pierre KAuthor Commented:
@Dave - let me give you more info in trying to answer the SSH question

I'm a MSAccess developer so the script is running in code inside my app and therefore at each Client so I need to "automate" the process.

Here is the VBA script for more info:

f = "C:\FTPScript.txt" 'creates the file that holds the FTP commands

Open f For Output As #1
Print #1, "open ftp.mysite.co.za" 'replace ftp.server with the server address
Print #1, "myusername" 'login id here
Print #1, "mypass" 'login password here
Print #1, "cd " & " public_html" 'Directory of file location
Print #1, "cd " & " quali" 'Sub-Directory of file location
Print #1, "ascii"
Print #1, "prompt"
Print #1, "del *.xml" 'Here goes the command that needs to delete the files
Print #1, "disconnect" 'disconnect the session
'Print #1, "bye"
'Print #1, "exit"
Close #1

Shell "C:\FTP.exe -s:C:\FTPScript.txt", vbHide

Open in new window


Does that help you? Can I do the same with SHH?
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

Dave BaldwinFixer of ProblemsCommented:
WinSCP can be scripted.  Here's some info: https://winscp.net/eng/docs/guide_automation
Pierre KAuthor Commented:
@Dave - I'll accept your answer and close the question on your WinSCP suggestion but I will only know if and how this works after a number of days downloading, learning and testing WinSCP scripting. It would also mean having to install it at each of my existing Clients for the script to work everywhere.
Also don't know if the same problem (not having root access) to the server will crop up when trying to delete those files.
Maybe I must change ISP or pay for them to run a automated script?
Thanks again

Just giving it a bit more time for someone with a out-the-box idea before I close it ok.
oBdACommented:
Instead of del, use mdelete, and start ftp.exe with -i to suppress the confirmation prompt.
f = "C:\FTPScript.txt" 'creates the file that holds the FTP commands

Open f For Output As #1
Print #1, "open ftp.mysite.co.za" 'replace ftp.server with the server address
Print #1, "myusername" 'login id here
Print #1, "mypass" 'login password here
Print #1, "cd " & " public_html" 'Directory of file location
Print #1, "cd " & " quali" 'Sub-Directory of file location
Print #1, "ascii"
Print #1, "prompt"
Print #1, "mdelete *.xml" 'Here goes the command that needs to delete the files
Print #1, "disconnect" 'disconnect the session
'Print #1, "bye"
'Print #1, "exit"
Close #1

Shell "C:\FTP.exe -s:C:\FTPScript.txt -i", vbHide

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Pierre KAuthor Commented:
@oBdA - Tears of joy and jumping on my seat.
It had to be that simple. Full marks and thanks!
Pierre KAuthor Commented:
PS: There was no need to use the i-switch since there was no confirmation prompts at all
oBdACommented:
Seems to be related to the ftp server; I tested it against a Microsoft FTP server, and without the -i, it prompted for every file.
Pierre KAuthor Commented:
On my side it would not run the code with the switch. It gave no code script errors but would not run.
So I'm so glad that I 'forgot' to add the switch in the code before testing so my initial test was with the 'mdelete' but without the switch.
If I added the 'mdelete' and the switch at the same time I might not have known that it works :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft DOS

From novice to tech pro — start learning today.