for /f "tokens=2 delims=[]" %%i in ('ver') do @set FullVer=%%i
for /f "tokens=2,3 delims=. " %%i in ('echo %FullVer%') do @set Ver=%%i
if %Ver% NEQ 5 mshta vbscript:CreateObject("Wscript.Shell").popup("请运行在 Windows XP 系统版本!",4,"提示",64)(window.close)&&exit
set drive=.
set choice=.
SETLOCAL ENABLEDELAYEDEXPANSION
set Name=
for /f "tokens=3" %%i in ('wmic logicaldisk where DriveType^=3 Get FileSystem^,FreeSpace^,Name^,Size^|findstr ":"') do if not %%i==%SystemDrive% set Name=%%i !Name!
set choice=!Name!
for %%i in (%choice%) do if exist %%i\nul if not exist "%%i\Windows\explorer.exe" set drive=%%i
SETLOCAL DISABLEDELAYEDEXPANSION
if "%drive%"=="." mshta vbscript:CreateObject("Wscript.Shell").popup("没有发现可用的驱动器!",4,"错误",64)(window.close)&&exit
if "%1"=="/?" goto help
if "%1"=="/h" goto help
if "%1"=="/H" goto help
if "%1"=="/u" goto copyfiles
if "%1"=="/U" goto copyfiles
echo 正在检测系统,请稍候...
for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Desktop" ^|findstr "Desktop"') do set Current_Desktop=%%b>nul 2>nul
for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Personal" ^|findstr "Personal"') do set Current_Personal=%%b>nul 2>nul
for /f "tokens=3*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Pictures" ^|findstr "Pictures"') do set Current_My_Pictures=%%b>nul 2>nul
for /f "tokens=3*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Video" ^|findstr "Videos"') do set Current_My_Video=%%b>nul 2>nul
if "%Current_My_Video%"=="" set Current_My_Video=%Current_Personal%\My Videos&® add "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /f /v "My Video" /t REG_SZ /d "%Current_Personal%\My Videos">nul 2>nul
for /f "tokens=3*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Music" ^|findstr "Music"') do set Current_My_Music=%%b>nul 2>nul
for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Favorites" ^|findstr "Favorites"') do set Current_Favorites=%%b>nul 2>nul
for /f "tokens=3*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Internet Explorer" /v "Download Directory" ^|findstr "Download"') do set Current_Downloads=%%b>nul 2>nul
if "%Current_Downloads%"=="" set Current_Downloads=%USERPROFILE%\Downloads&® add "HKCU\Software\Microsoft\Internet Explorer" /f /v "Download Directory" /t REG_SZ /d "%USERPROFILE%\Downloads">nul 2>nul
for /f "tokens=2*" %%a in ('REG QUERY "HKLM\SYSTEM\CurrentControlSet\Control\Nls\Language" /v "InstallLanguage" ^|findstr "InstallLanguage"') do set InstallLanguage=%%b>nul 2>nul
if %InstallLanguage%==0412 (
for /f "tokens=3*" %%a in ('REG QUERY "HKLM\SOFTWARE\Classes\CLSID\{00021400-0000-0000-C000-000000000046}" /ve ^|findstr "REG_SZ"') do set Desktop=%%b>nul 2>nul
) else (
for /f "tokens=2*" %%a in ('REG QUERY "HKLM\SOFTWARE\Classes\CLSID\{00021400-0000-0000-C000-000000000046}" /ve ^|findstr "REG_SZ"') do set Desktop=%%b>nul 2>nul
)
:input
cls
echo 当前目标文件夹位置:
echo.
echo 『桌面』 "%Current_Desktop%"
echo 『我的文档』 "%Current_Personal%"
echo 『图片收藏』 "%Current_My_Pictures%"
echo 『我的视频』 "%Current_My_Video%"
echo 『我的音乐』 "%Current_My_Music%"
echo 『收藏夹』 "%Current_Favorites%"
echo 『下载』 "%Current_Downloads%"
echo.
set Drive_Letter=%drive%
set /P Drive_Letter="请输入指令或目标驱动器(默认值:%drive%) [ H | Q | U | %choice%] "
echo.
rem 转换输入字符串为大写
for /f "delims=" %%a in ('tree "\$\%Drive_Letter%"^|find /i ":\$\%Drive_Letter%"') do set Drive_Letter=%%~nxa
set select=%Drive_Letter%
set Same=N
if "%Current_Desktop:~0,1%"=="%Drive_Letter:~0,1%" set Same=Y
if "%Drive_Letter%"=="" set Drive_Letter=%drive%
if "%Drive_Letter%"=="H" goto help
if "%Drive_Letter%"=="Q" mshta vbscript:CreateObject("Wscript.Shell").popup("正在退出向导...",2,"移动目标文件夹位置",64)(window.close)&&exit
if %select% NEQ U if %DelFile% EQU Y rd /s /q "%Current_Downloads%">nul 2>nul
rem 正在处理『图标缓存』...
attrib -r -a -s -h "%USERPROFILE%\AppData\Local\IconCache.db">nul 2>nul
del /f /q "%USERPROFILE%\AppData\Local\IconCache.db">nul 2>nul
taskkill /f /im explorer.exe
start explorer.exe
exit
:help
echo 移动目标文件夹位置
echo.
echo %~n0 [drive:] [/U] [/Q] [/H]
echo.
echo drive: 目标驱动器
echo /U 还原默认值
echo /Q 退出向导
echo /H 显示帮助
echo.
echo 命令行键入 %~n0,可以启动一个向导。
echo.
if "%1"=="" pause&&goto input
复制代码
作者: chishingchan 时间: 2017-12-3 23:11
@echo off
title 移动目标文件夹位置向导 by chishingchan
for /f "tokens=2 delims=[]" %%i in ('ver') do @set FullVer=%%i
for /f "tokens=2,3 delims=. " %%i in ('echo %FullVer%') do @set Ver=%%i
if %Ver% LSS 6 mshta vbscript:CreateObject("Wscript.Shell").popup("请运行在 Windows 7/8/10 系统版本!",4,"提示",64)(window.close)&&exit
set drive=.
set choice=.
SETLOCAL ENABLEDELAYEDEXPANSION
set Name=
for /f "tokens=3" %%i in ('wmic logicaldisk where DriveType^=3 Get FileSystem^,FreeSpace^,Name^,Size^|findstr ":"') do if not %%i==%SystemDrive% set Name=%%i !Name!
set choice=!Name!
for %%i in (%choice%) do if exist %%i\nul if not exist "%%i\Windows\explorer.exe" set drive=%%i
SETLOCAL DISABLEDELAYEDEXPANSION
if "%drive%"=="." mshta vbscript:CreateObject("Wscript.Shell").popup("没有发现可用的驱动器!",4,"错误",64)(window.close)&&exit
if "%1"=="/?" goto help
if "%1"=="/h" goto help
if "%1"=="/H" goto help
if "%1"=="/u" goto copyfiles
if "%1"=="/U" goto copyfiles
echo 正在检测系统,请稍候...
for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "{4C5C32FF-BB9D-43B0-B5B4-2D72E54EAAA4}" ^|findstr "Saved Games"') do set Current_Saved_Games=%%b
for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "{56784854-C6CB-462B-8169-88E350ACB882}" ^|findstr "Contacts"') do set Current_Contacts=%%b
for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "{BFB9D5E0-C6A9-404C-B2B2-AE6DB6AF4968}" ^|findstr "Links"') do set Current_Links=%%b
for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "{7D1D3A04-DEBB-4115-95CF-2F29DA2920DA}" ^|findstr "Searches"') do set Current_Searches=%%b
for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Favorites" ^|findstr "Favorites"') do set Current_Favorites=%%b
for /f "tokens=3*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Video" ^|findstr "Videos"') do set Current_My_Video=%%b
for /f "tokens=3*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Pictures" ^|findstr "Pictures"') do set Current_My_Pictures=%%b
for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Personal" ^|findstr "Documents"') do set Current_Personal=%%b
for /f "tokens=3*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "My Music" ^|findstr "Music"') do set Current_My_Music=%%b
for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "{374DE290-123F-4565-9164-39C4925E467B}" ^|findstr "Downloads"') do set Current_Downloads=%%b
for /f "tokens=2*" %%a in ('REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Desktop" ^|findstr "Desktop"') do set Current_Desktop=%%b
:input
cls
echo 当前目标文件夹位置:
echo.
echo 『我的文档』 "%Current_Personal%"
echo 『桌面』 "%Current_Desktop%"
echo 『下载』 "%Current_Downloads%"
echo 『收藏夹』 "%Current_Favorites%"
echo 『我的图片』 "%Current_My_Pictures%"
echo 『我的视频』 "%Current_My_Video%"
echo 『我的音乐』 "%Current_My_Music%"
echo 『保存的游戏』 "%Current_Saved_Games%"
echo 『联系人』 "%Current_Contacts%"
echo 『链接』 "%Current_Links%"
echo 『搜索』 "%Current_Searches%"
echo.
set Drive_Letter=%drive%
set /P Drive_Letter="请输入指令或目标驱动器(默认值:%drive%) [ H | Q | U | %choice%] "
echo.
rem 转换输入字符串为大写
for /f "delims=" %%a in ('tree "\$\%Drive_Letter%"^|find /i ":\$\%Drive_Letter%"') do set Drive_Letter=%%~nxa
set select=%Drive_Letter%
if "%Current_Desktop:~0,1%"=="%Drive_Letter:~0,1%" mshta vbscript:CreateObject("Wscript.Shell").popup("输入的盘符与当前的盘符相同!",2,"错误",64)(window.close)&&goto input
if "%Drive_Letter%"=="" set Drive_Letter=%drive%
if "%Drive_Letter%"=="H" goto help
if "%Drive_Letter%"=="Q" mshta vbscript:CreateObject("Wscript.Shell").popup("正在退出向导...",2,"移动目标文件夹位置",64)(window.close)&&goto end