1.

Solve : Batch Maintence Script for Sub Directories?

Answer»

Hello,
Im fairly new to cmd scripting and I have been trying to write a script that would go through a all of the sub-directories in a specific folder and run the following script which would save the 10 most recent FILES and delete the rest within that sub folder.

Code: [Select]for /f "skip=10 tokens=*" %%a in ('dir /a:-d /b /o:-d') do del %%a
The ISSUE i'm having is trying to figure out how to have this run in every single sub-directory, If anyone can POINT me in the right direction on how I can SOLVE this issue I would be forever GREATFUL, this is how my .bat file currently looks:

Code: [Select]@echo off &setlocal
set folder=C:\test\
pushd "%folder%"

for /f "skip=10 tokens=*" %%a in ('dir /a:-d /b /o:-d') do del %%a

popd

pauseDeleteme



Discussion

No Comment Found