Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1.  
  2.  
  3. @goto script
  4. This script was written for the elite dangerous. What it does is backup your current bindings to your desktop. You will then be able to restore the backups to the game folder. When backups are restored, it will backup the original folder then copy the backed up files into the game folder.
  5. Author b00st3d@nrevolt.net
  6. :script
  7. @echo off&setlocal enabledelayedexpansion
  8. cd %desktop%
  9. set savepath="%userprofile%\desktop\files\BindingsBackup"
  10. set bindings="%localappdata%\Frontier Developments\Elite Dangerous\Options\Bindings"
  11. title Backup and Restore Elite Dangerous Bindings
  12. :top
  13. cls
  14. echo Bindings location:
  15. echo %bindings%
  16. echo.
  17. echo Backup location:
  18. echo %savepath%
  19. echo.
  20. echo.
  21. echo ++++++++++++++++++++++++++++++++++++++++++++++++++
  22. echo + This script will backup your bindings folder +
  23. echo + to your desktop. +
  24. echo + +
  25. echo + 1. Backup bindings +
  26. echo + 2. Restore bindings +
  27. echo + 3. Open bindings folder +
  28. echo + 4. Open backup folder +
  29. echo + +
  30. echo + 5. Exit +
  31. echo + +
  32. echo ++++++++++++++++++++++++++++++++++++++++++++++++++
  33. echo.
  34. choice /C 12345 /N /M "Please enter a selection: "
  35. if %errorlevel% == 1 goto backup
  36. if %errorlevel% == 2 goto restore
  37. if %errorlevel% == 3 start "" %bindings%&goto top
  38. if %errorlevel% == 4 start "" %savepath%&goto top
  39. REM if the user doesn't select 1-4 automatically exit.
  40. exit
  41. :backup
  42. cls
  43. REM check if the savepath exists
  44. call :foldercheck %savepath%
  45. REM if the folder exists then warn the user they are about to overwrite
  46. if %errorlevel% == 1 (
  47. choice /C yn /N /M "Bindings have already been backed up. Would you like to overwrite? [y,n]: "
  48. if !errorlevel! == 1 rd /s/q %savepath%\&md %savepath%
  49. if !errorlevel! == 2 goto top
  50. ) else (
  51. REM if the folder doesn't exist then make it
  52. md %savepath% >nul
  53. )
  54. REM copy the bindings to the new backup folder
  55. xcopy /I /Q /S %bindings% %savepath%
  56. echo.
  57. echo Backup complete.
  58. echo Backup is located on your desktop in the BindingsBackup folder
  59. timeout 5 >nul
  60. goto top
  61. :restore
  62. cls
  63. REM check if the backup exists
  64. call :foldercheck %savepath%
  65. if %errorlevel% == 1 (
  66. REM warn the user they are about to overwrite their current bindings with a backup
  67. echo If you continue your current bindings will be replaced by the bindings located in
  68. echo %userprofile%\desktop\BindingBackup.
  69. echo.
  70. choice /c yn /n /m "Continue? [y,n]: "
  71. if !errorlevel! == 2 goto top
  72. if !errorlevel! == 1 (
  73. cd %bindings%
  74. cd ../
  75. REM backup the current folder to Bindings.bak just in case
  76. xcopy /I /S Bindings Bindings.bak
  77. REM delete the Bindings folder and everything in it
  78. rd /s/q Bindings
  79. REM Create a new bindings folder and move the backup into it
  80. md Bindings
  81. xcopy /I /S %savepath% %bindings%
  82. )
  83. ) else (
  84. echo Error! No backup located!
  85. timeout 3 >nul
  86. goto top
  87. )
  88. goto top
  89. REM This function comes from M. Jamal on https://stackoverflow.com/questions/138981/how-to-test-if-a-file-is-a-directory-in-a-batch-script
  90. REM This function will return an errorlevel depending on whether the supplied folderpath is valid.
  91. REM Errorlevel 0 means file/folder doesn't exist
  92. REM Errorlevel 1 means exists, and it is a folder
  93. REM Errorlevel 3 means exists, and it is a file
  94. :foldercheck <path>
  95. @pushd %~dp1
  96. @if not exist "%~nx1" (
  97. popd
  98. exit /b 0
  99. ) else (
  100. if exist "%~nx1\*" (
  101. popd
  102. exit /b 1
  103. ) else (
  104. popd
  105. exit /b 3
  106. )
  107. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement