Topic "Scripting - Delete all files and directories"

Author Message
Confuzed

Guest


I want my script to delete the entire contents of the remote working directory, files AND subdirectories.

It errors on the "rm *" if there is a directory in the remote working directory, and it appears that rmdir will not accept a wildcard.

I have tried both sftp and scp with no luck. Please advise.

Also, what happens if the remote working directory specified by the 'cd' command in my script is missing... does it default to something,or fail the script. I would hate to run the 'rm *' in the wrong directory!

Thanks,

Joe
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
Confuzed wrote:
I want my script to delete the entire contents of the remote working directory, files AND subdirectories.

That's not possible currently. But you can remote the whole directory and create new empty one.

Quote:
Also, what happens if the remote working directory specified by the 'cd' command in my script is missing... does it default to something,or fail the script.

That depends on configuration. See "help option" for "batch" option.
_________________
Martin Prikryl
Guest




prikryl wrote:
Confuzed wrote:
I want my script to delete the entire contents of the remote working directory, files AND subdirectories.

That's not possible currently. But you can remote the whole directory and create new empty one.


I'm not sure I follow you... could you explain a little clearer?

prikryl wrote:
Quote:
Also, what happens if the remote working directory specified by the 'cd' command in my script is missing... does it default to something,or fail the script.

That depends on configuration. See "help option" for "batch" option.


I did a "help option" and the only thing I can see that MAY help is the abort option. Would the inablity to open the remote directory I specify in the script result in an error that would cause the abort?

By the way, great product... I absolutely love people inspired enough to produce a valuable product for free... I love them even more when they offer such responsive support!
Guest




Anonymous wrote:

I did a "help option" and the only thing I can see that MAY help is the abort option. Would the inablity to open the remote directory I specify in the script result in an error that would cause the abort?


Just tested that and it does... now I just need to find a way to recursively delete all files and directories under the remote working directory.
Guest




[quote="Anonymous"]
prikryl wrote:
Confuzed wrote:
I want my script to delete the entire contents of the remote working directory, files AND subdirectories.

That's not possible currently. But you can remote the whole directory and create new empty one.


Nevermind... I figured it out... just did a
Code:
call rm -f -r -v *

and the files are gone!

Thanks again for a great product.

I'll try and convince my boss to donate!

Joe
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License