|
Answer» Hi alli need to search for a file on c PARTITION and delete it using a dos batch
so far i got untill
echo off DIR filetodelete/S >test1
thanks alot
also is it possible to compile it to binary / exeIts ALREADY been covered here... the first batch shows how to rename, but in comments you will see the dangerous delete instruction that you can use instead of rename.
http://stackoverflow.com/questions/15689510/batch-find-file-and-rename-it-find-file-and-delete-it
Quote Oh, it's great to have some good-loking programmers! Most programmers I know are UGLY.
for /f "delims=" %%i in ('dir /s /b /a-d "text.txt"') do (ren "%%i" text2.txt)
Should do the rename task. You should prepend the drive and starting DIRECTORY to the filename THOUGH, or it will rename ALL the text.txt files in ALL subdirectories. Hence ...dir /s/b "c:\users\kaster\text.txt"... will process "c:\users\kaster\" and all of the directories below and rename ALL of the files named text.txt to the NEW name.
It works by performing a DIRscan in /b basic mode (ie filenames only) /s including subdirectories /a-d ignoring matching directory names for files named "text.txt" - and the full filename is assigned to %%i. The delims clause makes sure that any spaces are not interpreted as delimiters.
See
`FOR ?`
from the prompt for documentation.
ANd if you are executing this directly from the prompt, change each %% to %
The second command is substantially easire
del /s "image1.jpg"
Again, prepend the starting path, and be VERY, VERY careful. This will delete ALL filenames matching "image1.jpg" in and under the specified directory.
Throughout, quoting the filenames ensures that spaces in file or directorynames are correctly processed.
|