@ echo off

rem Mai Dump Split Tool

rem

rem File Name (important): mymai_split.bat

rem

rem PURPOSE:

rem Splits mai dump folder into ZIP with small files (less than 10MB by default) and folder with big files for more efficient transfer.

rem

rem REQUIREMENTS:

rem GNU sed for Windows, Microsoft's forfiles.exe, WinRAR

rem Should be all installed and added to PATH environment variable.

rem

rem USAGE:

rem 1. Make empty folder.

rem 2. Put inside mai dump folder (like this PCSG00756) and mymai_split.bat (this file). Nothing else shoud be inside the folder.

rem 3. Run mymai_split.bat and when it's done you'll get ZIP with small files and folder with big files.

rem 4. Transfer them both to Vita's ux0:mai folder.

rem 5. Extract ZIP right there with VitaShell and delete now useless ZIP.

rem 6. Install game with MaiDumpTool as usual.

rem 7. Done.

rem

rem NOTE:

rem Tested on Windows XP and Windows 7.

rem Therefore can't guarantee correct operation under other OSes.

rem

echo Scanning files...

forfiles.exe /S /C "cmd /c if @ fsize lss 10485760 ( if @ isdir equ FALSE ( echo @ relpath )) " > mymai_list_of_files.txt

echo Formatting list...

ver | find "Windows XP" > nul

if % ERRORLEVEL % EQU 0 (

sed -i "s/ ^. / & \./" "mymai_list_of_files.txt"

)

sed -i "/mymai_list_of_files\.txt/d" "mymai_list_of_files.txt"

sed -i "/mymai_split\.bat/d" "mymai_list_of_files.txt"

echo Archiving...

winrar.exe a -afzip -df -ag -t small-files @ mymai_list_of_files.txt

echo Cleaning up...

del sed*

del mymai_list_of_files.txt

echo All Done.