Skip to content

Instantly share code, notes, and snippets.

@huanlin
Last active July 9, 2022 07:56
Show Gist options
  • Save huanlin/e0e57c6902cedbbc2d9229f8b4290ad9 to your computer and use it in GitHub Desktop.
Save huanlin/e0e57c6902cedbbc2d9229f8b4290ad9 to your computer and use it in GitHub Desktop.
Multiple Masks with forfiles and for commands
REM 把需要備份的檔案名稱全丟到 filelist.txt 裡面
del filelist.txt
for %m in (.txt, .pdf, .xls, .xlsx, .xlsm, .doc, .docx, .docm)
do (forfiles /S /M *%m /D +2021/01/01 /C "cmd /c echo @path" >> filelist.txt)
REM 把需要備份的檔案名稱全丟到 filelist.txt 裡面
del filelist.txt
forfiles /S /M "*.txt" /D +2021/01/01 /C "cmd /c echo @path" >> filelist.txt
forfiles /S /M "*.pdf" /D +2021/01/01 /C "cmd /c echo @path" >> filelist.txt
forfiles /S /M "*.xls" /D +2021/01/01 /C "cmd /c echo @path" >> filelist.txt
forfiles /S /M "*.xlsx" /D +2021/01/01 /C "cmd /c echo @path" >> filelist.txt
forfiles /S /M "*.xlsm" /D +2021/01/01 /C "cmd /c echo @path" >> filelist.txt
forfiles /S /M "*.doc" /D +2021/01/01 /C "cmd /c echo @path" >> filelist.txt
forfiles /S /M "*.docx" /D +2021/01/01 /C "cmd /c echo @path" >> filelist.txt
forfiles /S /M "*.docm" /D +2021/01/01 /C "cmd /c echo @path" >> filelist.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment