T
T
Tenebrius2016-02-23 23:42:03
Command line
Tenebrius, 2016-02-23 23:42:03

How to remove files containing a specific word in their name from a directory and subdirectories?

You need to make a bat-file, when launched, it will delete files from the folder in which it is located, and all subfolders.
wrote the following command:
del /F /S /P D:\path\*слово*.*
(for a specific folder)
But, apparently, something is wrong.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
res2001, 2016-02-24
@Tenebrius

You have already written everything, it remains only to save the command to the batch file and insert the parameter of the batch file in place of the word. Batch content:
del /F /S /P "D:\path\*%~1*"

Y
Yuri Chudnovsky, 2016-02-24
@Frankenstine

Since you specified the file name in the path directory alone, then for its subdirectories you must either specify this separately:
del /F /S /PD:\path\*\*word*.*
or (if the nesting is not known in advance) loop through recursively through subdirectories by doing
del /F /S /P *word*.*

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question