6

I would like to delete all files on a Windows server matching this wildcard:

E:\Cache\*\*\*_ROOT\a*_SYMBOL\weekly*

In linux, I could just put an rm -rf in front of it and it would work. If I try something similar in Windows, it just gives me:

The filename, directory name, or volume label syntax is incorrect.

Any ideas about what I can do?

1
  • 2
    I believe a batch file with FOR loops will be needed, not any one single command will work. I needed to write one to delete every subdirectory in a directory. You batch file would be similar but you would need to test for the name of the directories and travel down each subdirectory. For a while I did look for a third party RD command to accept wild cards but if we quicker for me to write my own. However, my situation was simple. Oct 5, 2010 at 18:32

3 Answers 3

3

Use Power Shell, which comes built-in in Win7

for example, rm -rf would translate to:

Remove-Item E:\Cache\*\*\*_ROOT\a*_SYMBOL\weekly* -force
2
  • It's Windows 2008 Server, but that includes PowerShell. Isn't that handy? Thanks a lot! Oct 7, 2010 at 11:26
  • What if I want to delete all folders with a certain name anywhere in the sub-tree, but starting at a certain root folder. E.g. delete all folders named TestResult within C:\Projects` and all subdirectories? Found the answer - example 4 of the Remove-Item` command explains it: get-childitem C:\Projects\* -include TestResults -recurse | remove-item
    – Pat
    Oct 11, 2010 at 21:00
0

Share the folder. Connect to the share with linux. Use ls to generate a list of files. Open up your favorite text editor and edit the list. Add del to the front of each line. Replace all / with \ and change the path from /cache to E:\ . Add quotes around each path to protect against the ^ in the filename and change all % into %%. Copy the contents into a .bat file and execute.

0

Cygwin is very useful for things like this, if you don't have a linux machine to share to. After you install it, you'll be able to execute the linux command directly on your windows folders.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .