James
James

Reputation: 13

Wildcard with cmd files

I am currently using this statement:

for /d %%X in (C:\Users\*) do (del %%X\Desktop\deleteme.txt )

Although I would like to use the "%%X" in to parts of this statement

e.g.

del %%X\%%X\deleteme.txt

How can this be done?

Any help would be greatly appreciated

Upvotes: 0

Views: 225

Answers (1)

Frank
Frank

Reputation: 1132

It seems like you want to recursively delete files. This could be done by using the del command directly. By typing:

del deleteme.txt /s

deleteme.txt will be deleted from all subfolders. If that is not what you want you also could have your for loop call another batch file to perform the deletion from sub folders.

%%X will not work, as it gets fully expanded first.

Upvotes: 1

Related Questions