Use Split2.bat
to split (and optionally encrypt) a file.
Use Combine2.bat
to combine (and optionally decrypt) files.
See here for FileSplitter.vbs
, UTF7Convert.vbs
and here for XorKeyCrypt.exe
.
!SplitAndCombine2 |
@echo off | |
setlocal enableextensions | |
if "%~1" == "/?" ( | |
echo Syntax: Combine2 KeyFile FileName | |
goto :eof | |
) | |
if "[%~1]" == "[]" ( | |
echo Missing parameter KeyFile. | |
exit /b 1 | |
) | |
set "_errorlevel=0" | |
if "[%~2]" == "[]" ( | |
echo Missing parameter FileName. | |
exit /b 1 | |
) else ( | |
call :isdir "%~2" | |
setlocal enabledelayedexpansion | |
if !_errorlevel! neq 0 ( | |
echo Invalid parameter FileName | |
exit /b 1 | |
) | |
endlocal | |
) | |
pause | |
set "_FILENAME=%~nx2" | |
set "_FOLDERNAME=%~dp2" | |
for /f "tokens=* delims=" %%I in ('dir /b "%_FOLDERNAME%"') do ( | |
call :xorkeycryptsub "%~1" "%_FOLDERNAME%%%I" "%_FOLDERNAME%%%I" | |
setlocal enabledelayedexpansion | |
if !_errorlevel! neq 0 exit /b 1 | |
endlocal | |
) | |
for /f "tokens=* delims=" %%I in ('cscript //nologo UTF7Convert.vbs /d /w "%_FILENAME%"') do ( | |
call :filesplittersub "%_FOLDERNAME%%_FILENAME%" "%%I" | |
setlocal enabledelayedexpansion | |
if !_errorlevel! neq 0 exit /b 1 | |
endlocal | |
) | |
goto :eof | |
:isdir | |
setlocal | |
set "_FILENAME=%~1.1" | |
for %%I in ("%_FILENAME%") do ( | |
set "_ATTR=%%~aI" | |
) | |
if [%_ATTR%] == [] ( | |
endlocal & set "_errorlevel=1" | |
goto :eof | |
) | |
set "_ATTRDIR=%_ATTR:~0,1%" | |
if %_ATTRDIR%==d ( | |
endlocal & set "_errorlevel=1" | |
goto :eof | |
) | |
goto :eof | |
:xorkeycryptsub | |
setlocal | |
XorKeyCrypt %1 %2 %3 | |
if %errorlevel% neq 0 ( | |
endlocal & set "_errorlevel=1" | |
goto :eof | |
) else ( | |
endlocal | |
goto :eof | |
) | |
:filesplittersub | |
setlocal | |
cscript //nologo FileSplitter.vbs /c %1 %2 | |
if %errorlevel% neq 0 ( | |
endlocal & set "_errorlevel=1" | |
goto :eof | |
) else ( | |
endlocal | |
goto :eof | |
) |
@echo off | |
setlocal enableextensions | |
if "%~1" == "/?" ( | |
echo Syntax: Split /pc:count^|/pm:size Key FileName | |
goto :eof | |
) | |
setlocal enabledelayedexpansion | |
if "[%~1]" == "[]" ( | |
echo Missing switches /pc or /ps. | |
exit 1 | |
) else ( | |
set "_SWITCH=%~1" | |
set "_SWITCH2=!_SWITCH:~0,3!" | |
if /i !_SWITCH2! == /pc ( | |
goto next | |
) | |
if /i !_SWITCH2! == /ps ( | |
goto next | |
) else ( | |
echo Missing switch /pc or /ps. | |
exit /b 1 | |
) | |
) | |
:next | |
setlocal disabledelayedexpansion | |
if "[%~2]" == "[]" ( | |
echo Missing parameter Key. | |
exit /b 1 | |
) | |
if "[%~3]" == "[]" ( | |
echo Missing parameter FileName. | |
exit /b 1 | |
) | |
for /f "tokens=* delims=" %%I in ('cscript //nologo UTF7Convert.vbs /e /w "%~n3"') do ( | |
set "_FILENAME=%%I" | |
) | |
cscript //nologo FileSplitter.vbs /s %_SWITCH% "%~3" "%_FILENAME%" | |
if %errorlevel% neq 0 exit /b 1 | |
set "_errorlevel=0" | |
for /f "tokens=* delims=" %%I in ('dir /b "%_FILENAME%"') do ( | |
call :xorcryptsub %~2 "%_FILENAME%\%%I" "%_FILENAME%\%%I" | |
setlocal enabledelayedexpansion | |
if !_errorlevel! neq 0 exit /b 1 | |
endlocal | |
call :filegensub "%_FILENAME%\%%I" | |
setlocal enabledelayedexpansion | |
if !_errorlevel! neq 0 exit /b 1 | |
endlocal | |
del /q "%_FILENAME%\%%I" | |
) | |
goto :eof | |
:xorcryptsub | |
setlocal | |
cscript //nologo XorCrypt.vbs %1 %2 %3 | |
if %errorlevel% neq 0 ( | |
endlocal & set "_errorlevel=1" | |
goto :eof | |
) else ( | |
endlocal | |
goto :eof | |
) | |
:filegensub | |
setlocal | |
cscript //nologo FileGen.vbs %1 | |
if %errorlevel% neq 0 ( | |
endlocal & set "_errorlevel=1" | |
goto :eof | |
) else ( | |
endlocal | |
goto :eof | |
) |