xendistar Posted May 3, 2015 Report Share Posted May 3, 2015 I want to use the forfile command in a batch file to delete a lot of files which are older than X days (files are added on a daily basis so the batch file will be run daily), these files are spread out through 14 seperate sub folders but there are two sub folders that I don't want forfiles to check. I want to use the /s syntax to make forfiles search recursesively through the (14) subfolders but how can I stop forfiles from checking the 2 subfolders I don't want it to check (moving the 2 sub folders is not an option). The only other way I can think of is to not use the /s syntax and write each path individually, does anybody know of an alternative way?? Quote Link to comment Share on other sites More sharing options...
Irene Posted May 3, 2015 Report Share Posted May 3, 2015 Sorry, I don't personally have any knowledge, but I wondered if anything here might help:https://technet.microsoft.com/en-gb/library/cc753551.aspx Quote Link to comment Share on other sites More sharing options...
xendistar Posted May 3, 2015 Author Report Share Posted May 3, 2015 I have seen that page and there is nothing on there to suggest that there is a don't look here option to go with the /s option. I am hoping that there are some hidden options that are not normally listed. Thanks for your helps though Quote Link to comment Share on other sites More sharing options...
Irene Posted May 3, 2015 Report Share Posted May 3, 2015 One suggestion in this thread is to make the files you want to preserve 'read-only':http://stackoverflow.com/questions/536109/command-line-to-recursively-delete-files-but-excluding-a-certain-file Quote Link to comment Share on other sites More sharing options...
LoganeMilligan Posted June 23, 2015 Report Share Posted June 23, 2015 You should go with these links, It will surely help you:http://stackoverflow.com/questions/23318731/how-to-use-multiple-commands-in-batch-using-forfiles-commandhttps://technet.microsoft.com/en-us/library/cc753551.aspx Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.