|
Answer» Hi Guys
New here, but it seems you know your stuff :-).
I guess my question is valid for all Windows versions...
I have a large amount of files sorted in folders by category, now I need to delete files under a surtain size in all the folders, how do I do that in one sweep? The files are in one root folder and from there the folders gets deep.. (I've been looking at det DOS commands, but none seem to fit (only xcopy seems to be ABLETO do stuff with folders)).
Thanks a lot.
PoulIn this example, files of less than 1000 bytes will be deleted. Place in the root folder of the folder tree concerned. Try it and edit the REM out when you are ready to actually delete the file. It will not delete itself.
Code: [Select]echo off for /f "delims=" %%F in ('dir /b /s /a-d ^| find /V "%~nx0"') do ( if %%~zF LSS 1000 ( echo deleting %%~dpnxF %%~zF bytes REM del "%%~dpnxF" ) )Hi
That looks great, but I need a little help; Where do I put this and how do I execute?
Thanks a lot!
PoulPerhaps this is a thing that you do not need to use very often and perhaps you would like to have some control over it manually. Instead of using a batch file, you can also do this manually by using the search function. Using Windows EXPLORER, go to the folder where you have the oversize files. Then using the search feature to look for all files that are larger than a certain size. This is an advanced search feature. I've used it to find files that I no longer want in a certain folder if they are over a certain size. Once you get the results of the search, you can delete the files individually even though they are in different PARTS of the folder tree. Also, if you don't want to delete them, you could move them to another folder. Just a suggestion. Works for me.
Quote from: Poul on December 12, 2010, 05:16:04 PM Where do I put this
Quote from: My EARLIER postPlace in the root folder of the folder tree concerned
Quote from: Poul on December 12, 2010, 05:16:04 PMand how do I execute?
The same way you execute any batch script.
Quote from: Geek-9pm on December 12, 2010, 05:36:24 PMPerhaps this is a thing that you do not need to use very often and perhaps you would like to have some control over it manually. Instead of using a batch file, you can also do this manually by using the search function. Using Windows Explorer, go to the folder where you have the oversize files. Then using the search feature to look for all files that are larger than a certain size. This is an advanced search feature. I've used it to find files that I no longer want in a certain folder if they are over a certain size. Once you get the results of the search, you can delete the files individually even though they are in different parts of the folder tree. Also, if you don't want to delete them, you could move them to another folder. Just a suggestion. Works for me.
This is a GREAT solution, I didn't know that was possible - thanks! :-)
Poul
|