set VBOXMANAGE="C:\Program Files\Oracle\VirtualBox\VBoxManage.exe"
IF NOT EXIST %VBOXMANAGE% (
echo %VBOXMANAGE% does not exist ... exiting)
)
ELSE (
IF EXIST input.vdi ( %VBOXMANAGE% closemedium disk input.vdi --delete)
IF EXIST output.vdi ( %VBOXMANAGE% closemedium disk output.vdi --delete)
IF EXIST output.img (%VBOXMANAGE% closemedium disk output.img)
REM use without .img
set /p INPUT_NAME="Enter input file name without .img: ";
set OUTPUT_NAME=%INPUT_NAME%_resized
set /p OUTPUT_SIZE="Enter Size (MB) (e.g. 15000): "
ECHO "========================================================================="
%VBOXMANAGE% convertfromraw %INPUT_NAME%.img input.vdi -format VDI --variant Standard
ECHO "========================================================================="
%VBOXMANAGE% createhd --filename output.vdi --size %OUTPUT_SIZE% --format VDI --variant Standard
ECHO "========================================================================="
%VBOXMANAGE% clonehd input.vdi output.vdi --existing
ECHO "========================================================================="
%VBOXMANAGE% clonehd output.vdi output.img --format RAW
copy output.img %OUTPUT_NAME%.img
%VBOXMANAGE% closemedium disk input.vdi --delete
%VBOXMANAGE% closemedium disk output.vdi --delete
%VBOXMANAGE% closemedium disk output.img
)