Monday, August 15, 2011

Clearing Sub-Folders in the Given Folder

Imagine: you have a shared folder where users can create there own sub-folders. Sometimes it is necessary to clean the whole shared folder, but the cleaning batch script has to leave all the sub-folders and just delete everything inside them. How to perform it? The small script below shows you quite an easy way to solve this problem. Hope you'll find it useful.
@echo off
pushd "U:\Share Folder"
for /d %%i in (*) do (
pushd "%%i"
rd /s /q "." 2>nul
popd
)
popd

No comments:

Post a Comment

Translate