user135596
user135596

Reputation:

Is there a way to delete all directories with the same name?

Long story short, I am trying to delete all .svn folders within my site.

I have tried to use a file mask: */.svn/*

Search in: /data/www/content/

But it's returning files named entries. It shows me all the directories the entries file is showing in which is helpful, but then I need to go to that directory and delete them one at a time.

Upvotes: 0

Views: 256

Answers (2)

Martin Prikryl
Martin Prikryl

Reputation: 202504

If you need to do this task repeatedly, you can write a PowerShell script using WinSCP .NET assembly.

There's already a Search recursively for text in remote directory example provided.

Your task is not that different. Instead of downloading ($session.GetFiles) and grepping a matching file, you delete it ($session.RemoveFiles).

Upvotes: 0

chrki
chrki

Reputation: 6333

The small help popup says that masks ending in / will find folders, so I tried .svn/ and it does find that in the current folder. But it does not search recursively in sub folders.

Since you are using WinSCP you probably have Bash or SSH access too, you could try one of the scripts mentioned in this Stackoverflow question: How to remove all .svn directories from my application directories

Upvotes: 2

Related Questions