
batrobocopyvbs整理備份桌面文件到d盤最后由 ygqiang 于 -6-4 18:39bat-robocopy-vbs,整理備份桌面文件到d盤需要用到robocopy.exe軟件
- @echo off & color 0d
- for /f tokens=2,* %%i in ('reg query HKCUSoftwareMicrosoftWindowsCurrentVersionExplorerShell Folders /v Desktop') do (
- set desktop_dir=%%j
- )
- ——————————————————————————————————————————————
- set back_dir=d:桌面?zhèn)浞?date:~0,4%-%date:~5,2%桌面?zhèn)浞?li>set back_dir1=%date:~0,4%-%date:~5,2%桌面?zhèn)浞?li>
- set back_dir_favo=d:桌面?zhèn)浞?date:~0,4%-%date:~5,2%桌面?zhèn)浞菔詹貖A
- if not exist d:桌面?zhèn)浞?(md d:桌面?zhèn)浞?
- if not exist %back_dir% (md %back_dir%)
- if not exist %back_dir_favo% (md %back_dir_favo%)
- 1set filesdate=%date:~0,4%%date:~5,2%%date:~8,2%
- ——————————————————————————————————————————————
- 00-00robocopy %desktop_dir% %back_dir% /move /e /xf *.lnk
- 00-00robocopy %userprofile%Favorites d:0beifen備份7Favorites /mir /w:2 /r:2
- 00-00robocopy %userprofile%Favorites %back_dir_favo% /mir /w:2 /r:2
- ——————————————————————————————————————————————
- for /f delims= %%a in ('dir /a-d /b /s %desktop_dir%*.*') do (
- if %%~xa neq .lnk (del %%a /f /s /q)
- )
- for /f delims= %%b in ('dir /ad /b /s %desktop_dir%^|sort /r') do (rd %%b /s /q)
- ——————————————————————————————————————————————
- (echo Set objShell=CreateObject^(Wscript.Shell^)
- echo DesktopPath=objShell.SpecialFolders^(Desktop^)
- echo Set objlink=objShell.CreateShortcut^(DesktopPath ^& %back_dir1%.lnk^)
- echo objlink.Hotkey=CTRL+Q
- echo objlink.WindowStyle=3
- echo objlink.TargetPath=%back_dir%
- echo objlink.Save
- )>%temp%mysendto.vbs
- start /wait %temp%mysendto.vbs
- cls
- ping 127.0.0.1 -n 5 >nul 2>nul
- del /q %temp%mysendto.vbs
- ——————————————————————————————————————————————
- title 重啟explorer資源管理器不關閉打開的文件夾
- 1set/p p=即將重啟 Explorer,<nul & 1pause
- Call :_RestartExplorer
- echo 完成!
- 1pause
- cls
- ping 127.0.0.1 -n 5 >nul 2>nul
- start %back_dir%
- exit
- :: 重啟 Explorer
- goto :eof
- :_RestartExplorer
- ( echo Set objWsh = CreateObject^(Wscript.Shell^)
- echo Set objShell = CreateObject^(Shell.Application^)
- echo For Each objWin In objShell.Windows
- echo If Instr^(LCase^(objWin.FullName^),explorer.exe^) Then
- echo strURL = strURL ^& objWin.LocationURL ^& vbCrLf
- echo End If
- echo Next
- echo If strURL = Then Wscript.Quit
- echo strURL = Left^(strURL, Len^(strURL^)-Len^(vbCrLf^)^)
- echo arrURL = Split^(strURL, vbCrLf^)
- echo objWsh.run cmd /c taskkill /f /im explorer.exe & start explorer, 0, True
- echo For Each strURL In arrURL
- echo objShell.Explore strURL
- echo Next )>%temp%RestartExplorer.vbs
- Cscript //NoLogo %temp%RestartExplorer.vbs
- del /q /f %temp%RestartExplorer.vbs
- goto :eof
nclick="copycode($('code0'));">復制代碼