Scripting - Delete all files and directories

Advertisement

Confuzed
Guest

Scripting - Delete all files and directories

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

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: Scripting - Delete all files and directories

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.

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.

Reply with quote

Guest

Re: Scripting - Delete all files and directories

martin 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?

martin wrote:

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!

Reply with quote

Guest

Re: Scripting - Delete all files and directories

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.

Reply with quote

Guest

Re: Scripting - Delete all files and directories

[quote="Anonymous"]

martin 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
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

Reply with quote

Advertisement

You can post new topics in this forum