I had created one batch file.In this I have stored:
My query's o/p into file named List.txt Its contains multiple files.
I want to delete these files which are contains in List.txt
.
I am writing code :
set file=E:\AppData\List.txt
findstr /s /p /x /m /c:"test" *.txt> %file%
for /F "tokens=* delims=" %%A in (%file%) Do
(
echo %%A
set name = "E:\AppData\%%A"
del %name%
)
pause
I can not access %name% value. How can I delete these files?
My List.txt
contains 4 files :
Data\Application 1\1.txt
Data\Application 1\4.txt
Data\Application 2\1.txt
Data\Application 2\4.txt
Data\Application 3\1.txt
EDIT
I made complete batch file and when i run it i get an error
The syntax of the command is incorrect.
E:\AppData\Data>for /F "tokens=* delims=" %A in (E:\AppData\List.txt) Do
I share my batch script here please can anyone find my mistake please.
@echo off
set file=E:\AppData\List.txt
findstr /s /p /x /m /c:"test" *.txt> %file%
:END
echo Files are Safe not deleted.
call "E:\batch files\linecount.bat"
SET /P "ANSWER=Click Y to delete all Files or N to stop (Y/N)"
for /F "tokens=* delims=" %%A in (%file%) Do
(
echo %%A
del "E:\AppData\%%A"
)
echo Files are deleted successfully.
pause