|
Answer» Hi , I want to prepare a batch file to delete some of the files in the folder. For eg: C:\Users\rkhatavkar\New folder contains 20 files. 15 files contains the word "Content" in the filename i.e C:\Users\rkhatavkar\New folder\Content1,C:\Users\rkhatavkar\New folder\Content2 ......C:\Users\rkhatavkar\New folder\Content15. I want to delete the remaining 5 files which does not have the word Content in it. Can we CREATE a batch file for deleting these files which do not have the word "Content" in the filename?? Please help......Run this in the new folder DIRECTORY. It will echo the del COMMANDS to the console only. Remove the 'echo' keyword if you are happy with it to enable the deletions.
Code: [Select]@echo off for /f %%a in ( ' DIR /b /a-d ^| find /v /i "content" ' ) do if /i not "%%a"=="%~nx0" echo del "%%a" pause Thank you very much. It works as expected.This is something that I'm looking for, only I'm TRYING to delete .url file on the desktop that contains "ALLDATA Repair - " in the .url. The only script that I have deletes the specific file name.
FOR %%A IN ("%userprofile%\Desktop\ALLDATA Repair - Login.url") DO DEL %%ASee your later thread for a reply to this question.
|