标题: [系统相关] bat-robocopy-vbs,整理备份桌面文件到d盘 [打印本页]
作者: ygqiang 时间: 2015-1-25 16:58 标题: bat-robocopy-vbs,整理备份桌面文件到d盘
本帖最后由 ygqiang 于 2016-6-4 18:39 编辑
bat-robocopy-vbs,整理备份桌面文件到d盘
需要用到robocopy.exe软件- @echo off & color 0d
- for /f "tokens=2,*" %%i in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Desktop"') do (
- set "desktop_dir=%%j"
- )
-
- ——————————————————————————————————————————————
- set "back_dir=d:\桌面备份\%date:~0,4%-%date:~5,2%桌面备份"
- set "back_dir1=%date:~0,4%-%date:~5,2%桌面备份"
-
- set "back_dir_favo=d:\桌面备份\%date:~0,4%-%date:~5,2%桌面备份\收藏夹"
-
-
- if not exist "d:\桌面备份" (md "d:\桌面备份")
- 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:\00beifen\备份\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
复制代码
作者: erjnasrtnws 时间: 2016-1-9 07:44
我有空试用下 谢谢分享 我也请高手帮忙写过一个类似的 !!
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |