Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #unpack hdf file(s), rename, and repack
- # set -x # verbose
- # remove temp directory if it exists
- rm -r temp*
- #for each .hdf file in the current directory
- for x in ./*.hdf; do
- # print the hdf filename
- echo $x
- # unpack the hdf file
- xdftool -f $x unpack ./temp
- # find the .slave files and return the count
- find . -iname *.slave | wc -l
- # create variable test with the count
- test=`find . -iname *.slave | wc -l`
- # check if test is greater than 0 (there is at least one slave file)
- if [ $test -gt 0 ]; then
- # print that the slave file exists
- echo "Slave file exists"
- # find the slave file and change to that directory
- cd "$(find ./ -name *.Slave -printf '%h' -quit)"
- cd "$(find ./ -name *.slave -printf '%h' -quit)"
- # create variable that stores this directory name
- dirname=${PWD##*/}
- # print directory name
- echo $dirname stored
- # change "XXXXX.slave" to "game.slave"
- find . -iname '*.Slave' -execdir mv -n {} game.slave \;
- # print that it was renamed
- echo "renamed to game.slave"
- # get the total size of files in the current directory and subdirectories
- total_size=`du -s | cut -f1`
- # create a multiplier value of 1.25
- m=1.25
- # create a variable that multiplies total_size by m
- hdfsize=$(expr $m*$total_size | bc)
- # turn that value into a string with a "K" at the end
- hdfsize+="K"
- # go back a directory
- cd ..
- # print "packing"
- echo "packing"
- #pack the renamed game files back into an HDF with hdfsize
- xdftool -f $x.repack.hdf pack ./$dirname size=$hdfsize
- # print packed
- echo "packed"
- # make the sizes 0 again (probably not necessary)
- total_size=0
- hdfsize=0
- # print "moving"
- echo "moving"
- # move the file to the c:drive in the AMIGAREPACK folder
- mv $x.repack.hdf /mnt/c/AMIGAREPACK
- echo "moved"
- # change back to the original directory with all of the hdf files
- # will need to be changed to your directory
- cd /mnt/e/1/home/pi/RetroPie/roms/amiga-data/Games_HDF
- # change directory name variable to current directory
- dirname=${PWD##*/}
- # print that directory name
- echo back to $dirname
- # if there was no slave file in the check above
- else
- # print no slave file
- echo "No Slave file - doing nothing"
- fi
- # remove the temp directory
- rm -r temp*
- echo "Done.."
- # end script
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement