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.
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:
@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
pause