本帖最后由 523066680 于 2016-10-22 12:49 编辑
声明:因为想到了所以写了,比较务实的客官请绕道。
制作要求:
1. 只能用move移动,不使用copy
2. 不管放在哪个中间目录,打开的时候都能接着进行移动,直到最后一个目录为止 | :: 遍历目录并不断移动位置的批处理 | | :: 523066680@163.com | | :: 阶段:初步完成 | | :: 备注:给这个脚本取名暂时不能有空格 | | | | @echo off | | setlocal enabledelayedexpansion | | if "%cd%"=="%~d0\" (type nul>%~d0\rcd_path.x) | | :: 把遍历过的路径写到根目录 | | echo %cd% >>%~d0\rcd_path.x | | title %cd% | | set /a i=0 | | for /f "tokens=*" %%a in ('dir /ad /b') do ( | | set /a i+=1 | | set F!i!=%%~fsa | | ) | | | | if %i% neq 0 (goto :into) else (goto :pre_next) | | exit | | | | :into | | ( | | move "%~fs0" "%F1%" | | echo %F1% | | cd "%F1%" | | start %~nx0 | | exit | | ) | | | | :pre_next | | | | echo %cd% | | echo in_pre_next | | | | for %%v in ("%cd%") do set current=%%~fsv | | cd .. | | if "%current%"=="%cd%" ( | | echo %cd% | | echo This is final station. | | pause | | exit | | ) | | | | set mark=0 | | set "F1=" | | | | for /f "tokens=*" %%a in ('dir /ad /b') do ( | | if !mark!==1 ( | | echo Next Station %%a | | set F1=%%~fsa | | goto :into | | ) | | if "%current%" == "%%~fsa" ( | | set mark=1 | | ) | | ) | | | | if "%F1%"=="" ( | | goto :pre_next | | )COPY |
测试情况,用Dev-cpp目录设置了共享,映射到X: 驱动器
然后把脚本放到X: 执行,输出结果对比Tree结果: | X:\ X:. | | X:\bin ├─bin | | X:\Examples ├─Examples | | X:\Examples\FileEditor │ ├─FileEditor | | X:\Examples\Hello │ ├─Hello | | X:\Examples\Jackpot │ ├─Jackpot | | X:\Examples\MDIApp │ ├─MDIApp | | X:\Examples\OpenGL │ ├─OpenGL | | X:\Examples\Simpwin │ ├─Simpwin | | X:\Examples\WinAnim │ ├─WinAnim | | X:\Examples\WinMenu │ ├─WinMenu | | X:\Examples\WinTest │ └─WinTest | | X:\Help ├─Help | | X:\Icons ├─Icons | | X:\include ├─include | | X:\include\c++ │ ├─c++ | | X:\include\c++\3.4.2 │ │ └─3.4.2 | | X:\include\c++\3.4.2\backward │ │ ├─backward | | X:\include\C__~1\342E8D~1.2\bits │ │ ├─bits | | X:\include\C__~1\342E8D~1.2\debug │ │ ├─debug | | X:\include\C__~1\342E8D~1.2\ext │ │ ├─ext | | X:\include\C__~1\342E8D~1.2\mingw32 │ │ └─mingw32 | | X:\include\C__~1\342E8D~1.2\mingw32\bits │ │ └─bits | | X:\include\ddk │ ├─ddk | | X:\include\GL │ ├─GL | | X:\include\sys │ └─sys | | X:\Lang ├─Lang | | X:\lib ├─lib | | X:\lib\debug │ ├─debug | | X:\lib\gcc │ └─gcc | | X:\lib\gcc\mingw32 │ └─mingw32 | | X:\lib\gcc\mingw32\3.4.2 │ └─3.4.2 | | X:\lib\gcc\mingw32\3.4.2\include │ └─include | | X:\libexec ├─libexec | | X:\libexec\gcc │ └─gcc | | X:\libexec\gcc\mingw32 │ └─mingw32 | | X:\libexec\gcc\mingw32\3.4.2 │ └─3.4.2 | | X:\mingw32 ├─mingw32 | | X:\mingw32\bin │ ├─bin | | X:\mingw32\lib │ └─lib | | X:\mingw32\lib\ldscripts │ └─ldscripts | | X:\Packages ├─Packages | | X:\TEMPLA~1 └─TemplatesCOPY |
|