Discussion Locked

Removing Directories using Command Line

0 helpful
10 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Can you delete a directory by using a wild card operator or do you have to type the exact name of the directory. For example I have many directorys every week that a program creates which all include the string .lnk such as hello.lnk. I want to use this uniqueness to delete many directories with the same string included in them.

Thanks
Roland

10 replies

by kirkhuyser

Unfortunately you'll have to type the exact name, as wild card characters do not work when using the rmdir command (rd is the short version).

by otl

No, because DOS uses the hexadecimal value to rmdir and mkdir.

A work around would be to do a DIR > (temporary text file)
Import into excel to get all .INK
separated from regular files, add a string in front of the path.
Save the text file.

If there are files in these directories;
Reopen in Word and replace the front end string and tab with "DEL " then replace tab and
with " *.*" then replace all tab with "." and save as a .BAT run this .BAT file to erase all files in the .INK directories

Reopen in Word and replace the front end string and tab with "rmdir " then replace tab and
with " " then replace all tab with "." and save as a .BAT, run the .BAT file.

Sorry long and slightly involved process, but the only work around I know of for DOS.

For Windows, open primary directory these sub-directories are in and index by file type, high-light the first then go to the bottom, hold the shift key and click on the last one, hit the delete key.

Best I can come up with,

Good Luck!

by otl

Creating the .BAT files will work if the directory names are always the same, then call the .BAT files at preset intervals (DAILY, WEEKLY, MONTHLY). If the file or directory does not exist, no problem. When new DIR's appear add another line to clearand remove that directory, continously.

by mike

There is a batch file that I had somewhere that would pipe the directories to a text file then use the text file to do a recursive delete followed by a rd to do what you need. I'll let you know if I find it.

by mike

There is a batch file that I had somewhere that would pipe the directories to a text file then use the text file to do a recursive delete followed by a rd to do what you need. I'll let you know if I find it.

This discussion is closed to new replies.