Batch file to delete all but latest two files

12:59 pm Uncategorized


@echo off
set folder=C:\test

pushd "%folder%"
for /f "skip=2 tokens=*" %%i in ('dir /a:-d-s /b /o:-d') do echo "%%i"
popd

*** Stolen from Major Geeks forum member GermanOne

Leave a Comment

Your comment

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.