dooferorg

Elite Dangerous bindings backup (Vincent Chu)

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