Windows bat file remove all file and folder excluding some file and folder -
i want delete files , folder in directory excluding file , folder in bat file.
i need keep these file, update.bat foldername.zip foldername
, other should deleted directory,
i wrote .bat file seems foldername
deleted directory, rest working fine.
can tell wrong below script?
attrib +r update.bat attrib +r foldername.zip attrib +r foldername /f "delims=" %%i in ('dir /b') (rmdir "%%i" /s/q || del "%%i" /s/q) attrib -r update.bat attrib -r foldername.zip attrib -r foldername
thanks haris
you misunderstanding how "read only" works folders in windows. it's not fault. it's misleading label. "read only" on folder makes files within folder read only, but not folder itself.
note
setting folder read-only makes files in folder read-only. not affect folder itself.
my apologies quoting vista documentation, wasn't able find similar page folders windows 7. mentioned in ui though:
how work around this?
we going set system
attribute well.
attrib +r update.bat attrib +r foldername.zip attrib +r +s foldername /f "delims=" %%i in ('dir /b') (rmdir "%%i" /s/q || del "%%i" /s/q) attrib -r update.bat attrib -r foldername.zip attrib -r -s foldername
example utilization:
before running update, directory contains following:
<dir> foldername foldername.zip new bitmap image.bmp <dir> new folder new microsoft word document.docx new text document (2).txt new text document (3).txt new text document.txt update.bat
after executing update.bat
, directory looks this:
<dir> foldername foldername.zip update.bat
Comments
Post a Comment