展开/折叠文件夹的小工具(cmd脚本)
fold.cmd
- @echo off
- setlocal enabledelayedexpansion
- set outpath=%~dp0
- set outpath=%outpath:~0,-1%_fold
- echo %outpath%
- if not exist %outpath% md %outpath%
- for /f "tokens=*" %%i in ('dir/b/a-d') do (
- set tt=%%i
- set tb=!tt:%~dp0=!
- set tb=%outpath%\!tb:_=\!
- set ta=!tb!
- for %%F in ("!ta!") do set ta=%%~dpF
- if not exist "!ta!" md "!ta!"
- copy "%%i" "!tb!"
- )
- pause
unfold.cmd
- @echo off
- setlocal enabledelayedexpansion
- set outpath=%~dp0
- set outpath=%outpath:~0,-1%_unfold
- echo %outpath%
- if not exist "%outpath%" md "%outpath%"
- for /f "tokens=*" %%i in ('dir/s/b/a-d') do (
- set tt=%%i
- set tt=!tt:%~dp0=!
- copy "%%i" "%outpath%\!tt:\=_!"
- )
- pause