Skip to content

Instantly share code, notes, and snippets.

@Ratstail91
Created October 16, 2014 07:07
Show Gist options
  • Save Ratstail91/606787384fff1864e13b to your computer and use it in GitHub Desktop.
Save Ratstail91/606787384fff1864e13b to your computer and use it in GitHub Desktop.
I wrote this during high school, when I was only just beginning to use programming languages over 3rd party engines (Game Maker); 6 years later it's aged really well. Built for Windows, it copies the entire contents of a USB drive to a defined folder. There are checks and precautions in place: the name of the backup folder is defined in the scri…
@ECHO OFF
ECHO USB Backup Utility designed by Kayne Ruse.
SET folder=USBBackup
ECHO Instructions
ECHO.
ECHO 1) There must be a folder called "%folder%" in this directory.
ECHO 2) The USB must have a copy of this file in it's root directory.
ECHO.
:getDrive
SET /P drive=Enter USB drive (one letter):
IF NOT EXIST %drive%:\%~nx0 GOTO getDrive
IF NOT EXIST %folder% GOTO getDrive
COPY %~nx0 %drive%:\%~nx0 > NUL
COPY %drive%:\%~nx0 %folder%\%~nx0 > NUL
ECHO.
ECHO Copy the %drive%: drive files?
SET /P choice= (y)es, (n)o, (s)hutdown or (r)estart:
ECHO.
IF NOT %choice%==y (
IF NOT %choice%==s (
IF NOT %choice%==r (
GOTO end
)
)
)
XCOPY %drive%:\ %folder% /D /E /Y
IF %choice%==y GOTO end
IF %choice%==s (
SHUTDOWN -s -f -t 30
ECHO Shutdown in progress
)
IF %choice%==r (
SHUTDOWN -r -f -t 10
ECHO Restart in progress
)
:abort
SET /P abort=Enter (a) to abort:
IF %abort%==a (
SHUTDOWN -a
GOTO end
) ELSE (
GOTO abort
)
:END
ECHO.
ECHO Program ended
PAUSE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment