# Scriptrunner for https://3ds.hacks.guide/finalizing-setup file copying operations
# Ver. 1.9.0 - Last modified: 2024-04-07
set PREVIEW_MODE "Finalizing Setup Helper Script\n> Copying SD files..."
set WRITE 0:/WRITE
rm -o -s $[WRITE]
if fdummy $[WRITE] 400
rm -o -s $[WRITE]
else
set PREVIEW_MODE "Finalizing Setup Helper Script\n> Copying SD files... :("
echo "Error #24: SD is write-protected\n \nYour SD card is set to read-only.\nEnsure that the lock switch is flipped\nin the upright position.\nOtherwise, your SD card may be failing.\n \nIf this error persists, ask for help\non Discord: https://discord.gg/MWxPgEp"
poweroff
end
if find -f "0:/finalize (*).romfs" ROMFS
cp -w -o -s $[ROMFS] 0:/finalize.romfs
rm -o -s $[ROMFS]
end
if find -f "0:/3ds/finalize (*).romfs" ROMFS
cp -w -o -s $[ROMFS] 0:/finalize.romfs
rm -o -s $[ROMFS]
end
if find -f "0:/luma/payloads/finalize (*).romfs" ROMFS
cp -w -o -s $[ROMFS] 0:/finalize.romfs
rm -o -s $[ROMFS]
end
if find -f "0:/luma/finalize (*).romfs" ROMFS
cp -w -o -s $[ROMFS] 0:/finalize.romfs
rm -o -s $[ROMFS]
end
if find -f "0:/DCIM/finalize (*).romfs" ROMFS
cp -w -o -s $[ROMFS] 0:/finalize.romfs
rm -o -s $[ROMFS]
end
if find -f "0:/Nintendo 3DS/finalize (*).romfs" ROMFS
echo "Information #23: finalize.romfs in wrong location\n \nfinalize.romfs is in the wrong location.\nThis script will attempt to move it.\nPlease hit on the next few prompts."
cp -w -o -s $[ROMFS] 0:/finalize.romfs
rm -o -s $[ROMFS]
end
if find 0:/3ds/finalize.romfs NULL
cp -w -o -s 0:/3ds/finalize.romfs 0:/finalize.romfs
rm -o -s 0:/3ds/finalize.romfs
end
if find 0:/luma/payloads/finalize.romfs NULL
cp -w -o -s 0:/luma/payloads/finalize.romfs 0:/finalize.romfs
rm -o -s 0:/luma/payloads/finalize.romfs
end
if find 0:/luma/finalize.romfs NULL
cp -w -o -s 0:/luma/finalize.romfs 0:/finalize.romfs
rm -o -s 0:/luma/finalize.romfs
end
if find 0:/DCIM/finalize.romfs NULL
cp -w -o -s 0:/DCIM/finalize.romfs 0:/finalize.romfs
rm -o -s 0:/DCIM/finalize.romfs
end
if find "0:/Nintendo 3DS/finalize.romfs" NULL
echo "Information #23: finalize.romfs in wrong location\n \nfinalize.romfs is in the wrong location.\nThis script will attempt to move it.\nPlease hit on the next few prompts."
cp -w -o -s "0:/Nintendo 3DS/finalize.romfs" 0:/finalize.romfs
rm -o -s "0:/Nintendo 3DS/finalize.romfs"
end
if not find 0:/finalize.romfs NULL
set PREVIEW_MODE "Finalizing Setup Helper Script\n> Copying SD files... :("
echo "Error #21: finalize.romfs not found\n \nfinalize.romfs could not be found on the SD card.\nCopy it to root of SD and try again."
poweroff
end
if not sha 0:/finalize.romfs FINALIZE_SHA256SUM
set PREVIEW_MODE "Finalizing Setup Helper Script\n> Copying SD files... :("
echo "Error #22: finalize.romfs is invalid\n \nThe file finalize.romfs is corrupt or unreadable.\nRe-download it, copy it to root of SD, and try again.\n \nExpected: FINALIZE_SHA256SUM"
poweroff
else
imgmount 0:/finalize.romfs
cp -w -o -s G:/finalize/GodMode9.firm 0:/luma/payloads/GodMode9.firm
if not find 0:/gm9/scripts NULL
mkdir 0:/gm9/scripts
end
cp -w -o -s G:/finalize/finalize.gm9 0:/gm9/scripts/finalize.gm9
imgumount
end
if not boot 0:/luma/payloads/GodMode9.firm
echo "Error #25: Could not boot GodMode9\n \nThis normally happens due to insufficient SD space.\nPlease make at least 20MB of free space."
poweroff
end