Advertisement
Guest User

amiga,unpackrepackretroarch

a guest
Feb 14th, 2019
546
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. #!/bin/bash
  2. #unpack hdf file(s), rename, and repack
  3. # set -x # verbose
  4.  
  5. # remove temp directory if it exists
  6. rm -r temp*
  7. #for each .hdf file in the current directory
  8. for x in ./*.hdf; do
  9. # print the hdf filename
  10. echo $x
  11. # unpack the hdf file
  12. xdftool -f $x unpack ./temp
  13. # find the .slave files and return the count
  14. find . -iname *.slave | wc -l
  15. # create variable test with the count
  16. test=`find . -iname *.slave | wc -l`
  17. # check if test is greater than 0 (there is at least one slave file)
  18. if [ $test -gt 0 ]; then
  19. # print that the slave file exists
  20. echo "Slave file exists"
  21. # find the slave file and change to that directory
  22. cd "$(find ./ -name *.Slave -printf '%h' -quit)"
  23. cd "$(find ./ -name *.slave -printf '%h' -quit)"
  24. # create variable that stores this directory name
  25. dirname=${PWD##*/}
  26. # print directory name
  27. echo $dirname stored
  28. # change "XXXXX.slave" to "game.slave"
  29. find . -iname '*.Slave' -execdir mv -n {} game.slave \;
  30. # print that it was renamed
  31. echo "renamed to game.slave"
  32. # get the total size of files in the current directory and subdirectories
  33. total_size=`du -s | cut -f1`
  34. # create a multiplier value of 1.25
  35. m=1.25
  36. # create a variable that multiplies total_size by m
  37. hdfsize=$(expr $m*$total_size | bc)
  38. # turn that value into a string with a "K" at the end
  39. hdfsize+="K"
  40. # go back a directory
  41. cd ..
  42. # print "packing"
  43. echo "packing"
  44. #pack the renamed game files back into an HDF with hdfsize
  45. xdftool -f $x.repack.hdf pack ./$dirname size=$hdfsize
  46. # print packed
  47. echo "packed"
  48. # make the sizes 0 again (probably not necessary)
  49. total_size=0
  50. hdfsize=0
  51. # print "moving"
  52. echo "moving"
  53. # move the file to the c:drive in the AMIGAREPACK folder
  54. mv $x.repack.hdf /mnt/c/AMIGAREPACK
  55. echo "moved"
  56. # change back to the original directory with all of the hdf files
  57. # will need to be changed to your directory
  58. cd /mnt/e/1/home/pi/RetroPie/roms/amiga-data/Games_HDF
  59. # change directory name variable to current directory
  60. dirname=${PWD##*/}
  61. # print that directory name
  62. echo back to $dirname
  63. # if there was no slave file in the check above
  64. else
  65. # print no slave file
  66. echo "No Slave file - doing nothing"
  67. fi
  68. # remove the temp directory
  69. rm -r temp*
  70. echo "Done.."
  71. # end script
  72. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement