how to delete files and folders -


how delete files or folders start 2015 , 2014?

this have far, deletes files , folders under c:\temp folder

@title =  @echo on  set folder="c:\temp"  cd /d %folder%  /f "delims=" %%i in ('dir /b') (rmdir "%%i" /s/q || del "%%i" /s/q)  pause 

you use for loops walk through directory tree; for /r /d enumerates subdirectories recursively, , for /r returns files:

pushd "c:\temp" /r /d %%i in ("2014*" "2015*") (     rmdir /q "%%~fi" ) /r %%i in ("2014*" "2015*") (     del /q "%%~fi" ) popd 

or let dir /b /s return items, files , directories, , parse output for /f loop:

pushd "c:\temp" /f "eol=| delims=" %%i in ('     dir /b /s "2014*" "2015*" ') (     2> nul rmdir /q "%%~fi" || del /q "%%~fi" ) popd 

the 2>nul redirection avoids error messages returned rmdir, if current item file.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -