[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[系统相关] bat-robocopy-vbs,整理备份桌面文件到d盘

本帖最后由 ygqiang 于 2016-6-4 18:39 编辑

bat-robocopy-vbs,整理备份桌面文件到d盘
需要用到robocopy.exe软件
  1. @echo off & color 0d
  2. for /f "tokens=2,*" %%i in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v "Desktop"') do (
  3. set "desktop_dir=%%j"
  4. )
  5. ——————————————————————————————————————————————
  6. set "back_dir=d:\桌面备份\%date:~0,4%-%date:~5,2%桌面备份"
  7. set "back_dir1=%date:~0,4%-%date:~5,2%桌面备份"
  8. set "back_dir_favo=d:\桌面备份\%date:~0,4%-%date:~5,2%桌面备份\收藏夹"
  9. if not exist "d:\桌面备份" (md "d:\桌面备份")
  10. if not exist "%back_dir%" (md "%back_dir%")
  11. if not exist "%back_dir_favo%" (md "%back_dir_favo%")
  12. 1set "filesdate=%date:~0,4%%date:~5,2%%date:~8,2%"
  13. ——————————————————————————————————————————————
  14. 00-00robocopy "%desktop_dir%" "%back_dir%" /move /e /xf *.lnk
  15. 00-00robocopy "%userprofile%\Favorites" "d:\00beifen\备份\7Favorites" /mir /w:2 /r:2
  16. 00-00robocopy "%userprofile%\Favorites" "%back_dir_favo%" /mir /w:2 /r:2
  17. ——————————————————————————————————————————————
  18. for /f "delims=" %%a in ('dir /a-d /b /s "%desktop_dir%\*.*"') do (
  19. if "%%~xa" neq ".lnk" (del "%%a" /f /s /q)
  20. )
  21. for /f "delims=" %%b in ('dir /ad /b /s "%desktop_dir%\"^|sort /r') do (rd "%%b" /s /q)
  22. ——————————————————————————————————————————————
  23. (echo Set objShell=CreateObject^("WScript.Shell"^)
  24. echo DesktopPath=objShell.SpecialFolders^("Desktop"^)
  25. echo Set objlink=objShell.CreateShortcut^(DesktopPath ^& "\%back_dir1%.lnk"^)
  26. echo objlink.Hotkey="CTRL+Q"
  27. echo objlink.WindowStyle=3
  28. echo objlink.TargetPath="%back_dir%"
  29. echo objlink.Save
  30. )>"%temp%\mysendto.vbs"
  31. start /wait "" "%temp%\mysendto.vbs"
  32. cls
  33. ping 127.0.0.1 -n 5 >nul 2>nul
  34. del /q "%temp%\mysendto.vbs"
  35. ——————————————————————————————————————————————
  36. title 重启explorer资源管理器不关闭打开的文件夹
  37. 1set/p "p=即将重启 Explorer,"<nul & 1pause
  38. Call :_RestartExplorer
  39. echo 完成!
  40. 1pause
  41. cls
  42. ping 127.0.0.1 -n 5 >nul 2>nul
  43. start "" "%back_dir%"
  44. exit
  45. :: 重启 Explorer
  46. goto :eof
  47. :_RestartExplorer
  48.   ( echo Set objWsh = CreateObject^("WScript.Shell"^)
  49.   echo Set objShell = CreateObject^("Shell.Application"^)
  50.   echo For Each objWin In objShell.Windows
  51.   echo   If Instr^(LCase^(objWin.FullName^),"\explorer.exe"^) Then
  52.   echo     strURL = strURL ^& objWin.LocationURL ^& vbCrLf
  53.   echo   End If
  54.   echo Next
  55.   echo If strURL = "" Then WScript.Quit
  56.   echo strURL = Left^(strURL, Len^(strURL^)-Len^(vbCrLf^)^)
  57.   echo arrURL = Split^(strURL, vbCrLf^)
  58.   echo objWsh.run "cmd /c taskkill /f /im explorer.exe & start """" explorer", 0, True
  59.   echo For Each strURL In arrURL
  60.   echo   objShell.Explore strURL
  61.   echo Next )>"%temp%\RestartExplorer.vbs"
  62.   CScript //NoLogo "%temp%\RestartExplorer.vbs"
  63.   del /q /f "%temp%\RestartExplorer.vbs"
  64.   goto :eof
复制代码

我有空试用下 谢谢分享  我也请高手帮忙写过一个类似的  !!
这么好的论坛!!!!

TOP

返回列表