Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- set endcmd=echo.
- ::End cmd is a one line command that runs after this script. Do nothing 'echo.' is default.
- set steam=
- set launch=
- set redun=
- set link=
- set startin=
- set drive=
- set sum=
- set target=
- set value=
- set confirm=
- set CD=
- set removebat=
- set remove=
- setLocal EnableDelayedExpansion
- set verbose=0
- ::0=no
- ::1=verbose output
- set replace=0
- ::0=unspecified
- ::1=overwrite without prompt
- ::2=skip/ignore without prompt
- set param=0
- ::0=no parameters passed
- ::1=parameters passed to batch
- set quiet=0
- ::0=quiet mode off
- ::1=quiet mode active
- :start
- IF NOT "%1" == "" GOTO %1
- IF %param% == 1 GOTO skiptxt
- echo This batch file will create a virtual drive in your RAM and automatically copy
- echo (not move) a folder in the current directory onto aforementioned virtual
- echo drive. A junction will automaticall be created so you can use this batch file
- echo with Origin or Steam without any hassels.
- echo.
- echo Please do not include quotation marks in the filename or thousands separators
- echo in the integers. The easiest way to use this batch file is to copy it into the
- echo directory of the folder you wish to mount, F2 the folder as if you were going
- echo to rename it and copy the folder name as it appears. To paste in the command
- echo window you will have to right-click and select 'paste' from the context menu
- echo that appears.
- echo.
- :skiptxt
- IF NOT "%startin%" == "" (
- %startin:~,1%:
- cd "%startin%"
- )
- IF "%link%" == "" set /p link= Folder Name (in current directory):
- IF "%remove%" == "" set remove=%link%
- echo.
- IF %param% == 0 set /p drive= Drive Letter (Leave blank for default (R:)):
- IF "%drive%" == "" set drive=R
- :driveloopreturn
- call :strlen result drive
- IF EXIST "%drive%:" ( GOTO driveloop ) ELSE IF NOT %result% == 1 ( GOTO driveloop )
- set target=%drive%:\%link%
- IF %param% == 0 set /p sum= Set Ramdisk size in KiB (blank for automatic detection):
- IF "%redun%" == "" set /a redun=5
- IF "%sum%" == "" IF %param% == 0 set /p redun= Set Redundancy (extra space) between 1-99 (sans percentage sign, default 5):
- set /a redun=!redun!+100
- IF "%sum%" == "" GOTO extractsize
- :extractreturn
- GOTO writebat
- :writereturn
- GOTO mount
- :mountreturn
- MD "%target%"
- echo.
- echo Moving content to RAM Disk…
- robocopy "%link%" "%target%" /E /COPY:DAT /XJ /R:0 /W:0 >nul
- IF errorlevel 8 set sum=
- set /a redun=!redun!-99
- move "%link%" "%link%ORIGINAL"
- mklink /j "%link%" "%target%"
- echo.
- echo.
- IF "%sum%" == "" GOTO quietskip
- IF %verbose% == 1 (
- echo.
- echo.
- echo Redundancy value = !redun! %%
- echo Size = !sum! KiB
- echo Drive = %drive%
- echo Link = %link%
- echo Target = %target%
- echo Starting Directory = %startin%
- echo Launch = %launch%
- echo Steam Link = %steam%
- echo Quiet = %quiet%
- echo Replace = %replace%
- echo.
- echo.
- )
- IF NOT "%launch%" == "" start "Launching…" /WAIT "%link%\%launch%"
- IF NOT "%steam%" == "" start "Launching…" /WAIT "%steam%"
- IF NOT "%launch%%steam%" == "" GOTO dismount
- goto exit
- :extractsize
- set /a value=0
- FOR /R "%link%" %%I IN (*) DO (
- set /a value=%%~zI/1024
- set /a sum=!sum!+!value!
- )
- set /a sum=!sum!/100
- set /a sum=!sum!*!redun!
- GOTO extractreturn
- :dismount
- echo Close this window if you do not wish to proceed with mount removal and/or copy.
- echo.
- IF NOT "%steam%" == "" pause
- IF "%steam%" == "" IF %quiet% == 0 pause
- IF %replace% == 1 GOTO replaceloopend
- IF %replace% == 2 GOTO replaceskip
- :replaceloopstart
- set /p confirm= Overwrite folder on HDD with RAMDisk content? (Y or N):
- IF /I "%confirm%" == "N" GOTO replaceskip
- IF /I "%confirm%" == "Y" GOTO replaceloopend
- GOTO replaceloopstart
- :replaceloopend
- set replace=1
- rmdir "%link%"
- robocopy "%drive%:" "%CD%" /E /COPY:DAT /XJ
- :replaceskip
- echo.
- IF %quiet% == 1 GOTO quietskip
- echo Are you sure you want to remove the mount and return back to normal operation?
- pause
- :quietskip
- imdisk -D -m %drive%:
- rmdir "%link%"
- IF NOT %replace% == 1 move "%link%ORIGINAL" "%link%"
- IF %replace% == 1 RD /S "%link%ORIGINAL"
- del %removebat%
- IF "%sum%" == "" GOTO skiptxt
- GOTO exit
- :driveloop
- IF %quiet%%param% == 00 (set /p drive= Drive Letter in use or not valid, try again ^(type 'quit' to close this window^): ) ELSE GOTO exit
- IF "%drive%" == "quit" GOTO :eof
- GOTO driveloopreturn
- :strlen <resultVar> <stringVar>
- (
- set "s=!%~2!#"
- set "len=0"
- for %%P in (4096 2048 1024 512 256 128 64 32 16 8 4 2 1) do (
- if "!s:~%%P,1!" NEQ "" (
- set /a "len+=%%P"
- set "s=!s:~%%P!"
- )
- )
- )
- (
- set "%~1=%len%"
- exit /b
- )
- :writebat
- set removebat="remove%remove%.bat"
- echo @echo off>>%removebat%
- echo echo If you press a key the virtual drive in your RAM will be deleted. >>%removebat%
- echo echo Close this window if you do not wish to proceed.>>%removebat%
- echo echo.>>%removebat%
- IF %quiet% == 0 echo pause>>%removebat%
- IF NOT "%launch%%steam%" == "" (
- echo echo.>>%removebat%
- echo echo Are you sure you want to remove the mount and return back to normal operation?>>%removebat%
- IF %quiet% == 0 echo pause >>%removebat%
- echo.
- )
- echo imdisk -D -m %drive%:>>%removebat%
- echo rmdir "%link%">>%removebat%
- echo move "%link%ORIGINAL" "%link%">>%removebat%
- echo del %removebat%>>%removebat%
- GOTO writereturn
- :mount
- imdisk -a -s !sum!K -m %drive%: -p "/fs:ntfs /q /y"
- GOTO mountreturn
- :cycle2
- SHIFT
- :cycle1
- SHIFT
- set param=1
- GOTO start
- :-in
- :/in
- set startin=%~2
- GOTO cycle2
- :-f
- :/f
- set link=%~2
- GOTO cycle2
- :-d
- :/d
- set drive=%~2
- GOTO cycle2
- :-r
- :/r
- set /a redun=%~2
- GOTO cycle2
- :-s
- :/s
- set /a sum=%~2
- GOTO cycle2
- :-l
- :/l
- set launch=%~2
- GOTO cycle2
- :-st
- :/st
- set steam=%~2
- GOTO cycle2
- :-q
- :/q
- set quiet=1
- GOTO cycle1
- :-ow
- :/ow
- set replace=1
- GOTO cycle1
- :-iw
- :/iw
- set replace=2
- GOTO cycle1
- :-v
- :/v
- set verbose=1
- GOTO cycle1
- :-e
- :/e
- @echo on
- GOTO cycle1
- :-ec
- :/ec
- set endcmd=%~2
- set endcmd=%endcmd:""="%
- GOTO cycle2
- :exit
- IF %quiet% == 0 pause
- %endcmd%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement