39 lines
975 B
Bash
Executable File
39 lines
975 B
Bash
Executable File
#!/bin/bash
|
|
|
|
###uncomment below if required software not on system
|
|
#sudo apt-get install -y mame-tools p7zip-full
|
|
|
|
readonly sourcedir="$1"
|
|
readonly destdir="$2"
|
|
|
|
# procesa el fitxer
|
|
for zipfile in "${sourcedir}"/*.zip; do
|
|
gameName="$(basename "$zipfile" .zip)"
|
|
|
|
if [ -f "${destdir}/${gameName}.chd" ]; then
|
|
echo -e "\e[1m\e[41m${gameName}.chd already exists\033[0m"
|
|
else
|
|
echo -e "\e[1m\e[41mExtracting ${gameName}...\033[0m"
|
|
7z x "${zipfile}" -o"${destdir}/${gameName}-tmp"
|
|
|
|
#convet to chd
|
|
echo -e "\e[1m\e[41mConverting ${gameName}...\033[0m"
|
|
find "${destdir}/${gameName}-tmp/" -type f -iname "*.cue" -exec chdman createcd -i {} -o "${destdir}/${gameName}.chd" \;
|
|
|
|
#rm temporary directory
|
|
rm -rdf "${destdir}/${gameName}-tmp"
|
|
fi
|
|
|
|
### uncomment below to rm the original zip archive
|
|
#rm ./"$zipfile"
|
|
|
|
if [ "$3" = "-remove" ]; then
|
|
rm ./"$zipfile"
|
|
fi
|
|
|
|
echo "!!!!!!!!!!${gameName} complete..."
|
|
|
|
done
|
|
|
|
echo "All done."
|