Skip to content

Instantly share code, notes, and snippets.

Last active May 9, 2023 00:38
  • Star 9 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save nabilfreeman/ecc984a40af8632b360453389e784cac to your computer and use it in GitHub Desktop.
FAT32 File copier & splitter (works with Multiman)
# Are you using Mac OS X?
# You need to install coreutils for this to work.
# try `brew install coreutils`
# or `sudo port install coreutils`
# set a part size that works with FAT32 drives
# nice little intro
echo ""
echo ""
echo ""
echo "F R E E M A N I N D U S T R I E S"
echo ""
echo "This script copies a directory in its entirety to a new destination, and automatically splits files greater than 4gb along the way without compression."
echo ""
echo "The 3rd argument, prefix, is optional. If left out, files will be outputted as .00, .01."
echo "Here's an example - specify abc as the prefix, and the result will be .abc00, .abc01."
echo ""
echo "I built this to easily copy my PS3 backups to a FAT32 drive."
echo "For Multiman backups, specify 666 and the split files will be output as .66600, .66601 which Multiman successfully extracts."
echo ""
echo ""
echo ""
# validate args
USAGE="Usage: ./copyToFat32 \$INPUT_DIR \$OUTPUT_DIR \$PREFIX"
if [[ -z "$1" ]]; then
echo "You're missing \$INPUT_DIR."
echo $USAGE 1>&2
echo ""
exit 1
if [[ -z "$2" ]]; then
echo "You're missing \$OUTPUT_DIR."
echo $USAGE 1>&2
echo ""
exit 1
# grab input & output from arguments
INPUT_DIR=$(realpath $1)
OUTPUT_DIR=$(realpath $2)
# make sure the output dir exists.
mkdir -p "$OUTPUT_DIR"
# read through contents of input directory recursively...
find $INPUT_DIR | while read FILE; do
echo ""
# get the relative path by replacing the input directory prefix with a blank string. also replace the initial slash.
if [[ -d "$FILE" ]]
# this is a directory, so we create it at the destination.
mkdir -p "$RELATIVE_PATH"
echo "📁 Created a directory at $OUTPUT_DIR"
if [[ -f "$FILE" ]]
# this is a file, so we need to copy it over.
echo "📂 $FILE"
# get file size
FILE_SIZE=$(du -m "$FILE" | cut -f1)
# if the file is already smaller than the part size, we just need to copy it. splitting isn't necessary.
if [ "$FILE_SIZE" -le "$PART_SIZE" ]
echo "📋 This file is small enough to just be copied (${FILE_SIZE}mb)"
# if the file size is larger than the minimum, then we need to split it into parts.
if [ "$FILE_SIZE" -gt "$PART_SIZE" ]
echo "✂️ This file needs to be split into multiple parts (${FILE_SIZE}mb)"
if command -v gsplit >/dev/null 2>&1; then
gsplit -b "${PART_SIZE}m" -d "$FILE" "${RELATIVE_PATH}.${PREFIX}"
split -b "${PART_SIZE}m" -d "$FILE" "${RELATIVE_PATH}.${PREFIX}"
echo "✅ Saved to $RELATIVE_PATH"
Copy link

THank you for the code, I hope you see my comment...
I am new to PS3 games etc...
I only know that I have to exctract ISO file for gaming and installing into multiman, sometimes I have a pkg file of 16 Go for example of watch dog.
I want to know if I can use your script to split it? or when to use your script to split games...
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment