NT Batch Scripting

coughtryb

Member
Oct 21, 2004
59
0
0
I have a .txt file that contains a list of paths and directory names in the following format...

c:\users\john\gameinfo
c:\users\jane\gameinfo
c:\users\robert\gameinfo
(hundres more directories, all called gameinfo, but in different locations)

All I want to do is run RMDIR on each instance of 'gameinfo'. I am new to scripting but I know there has to be a way to do this. I have tried pipes and redirects without success. Any help would be appreciated.

Thanks friends!
Beni
 

KB

Diamond Member
Nov 8, 1999
5,406
389
126
This is easier to do in vbscript


try this code in a .vbs file, be sure to replace C:\file.txt with your text file
Dim fso

Set fso = CreateObject("Scripting.FileSystemObject")
Set oText = fso_OpenTextFile("C:\file.txt", 1)

Do Until oText.AtEndofStream
str = oText.ReadLine()

fso.DeleteFolder(str)
Loop

 

skace

Lifer
Jan 23, 2001
14,488
7
81
Assuming every single line in this text file is a gameinfo directory that you want to delete:
*** Also note, "%%" is used in an actual batch file, but if you were to run this command directly from dos you would only use 1 "%" per occurance.

(you may also want to add the /s /q switches to rmdir depending on the occasion)