Monday 17 December 2018

windows 7 - Batch File to Delete a folder if it doesnt contain a specific file

I have a folder with loads of subfolders. I need a batch file that looks down the list of subfolders and checks if a specified file exists. If the file does not exist then the sub folder can be deleted.


This needs to run on Windows 7 workstations.


I am getting my syntax mixed up in my for /f and if exist commands:


for /f /f%% in ('dir /b c:\test') do if exist "test.txt" rename c:\test\%% tobedeleted

I think I am either trying to do to much in one argument or am missing something vital.

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...