chd_from_zip.sh: Realiza comprobaciones de los parametros y de la existencioa del directorio de origen
This commit is contained in:
+17
-7
@@ -3,14 +3,26 @@
|
|||||||
###uncomment below if required software not on system
|
###uncomment below if required software not on system
|
||||||
#sudo apt-get install -y mame-tools p7zip-full
|
#sudo apt-get install -y mame-tools p7zip-full
|
||||||
|
|
||||||
readonly sourcedir="$1"
|
## Comprueba los parametros
|
||||||
readonly destdir="$2"
|
if [ "$#" -lt 2 ]; then
|
||||||
|
printf "Uso: chd_from_zip.sh SOURCEDIR DESTDIR [-remove]"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
readonly sourcedir="$1"
|
||||||
|
readonly destdir="$2"
|
||||||
|
fi
|
||||||
|
|
||||||
# procesa el fitxer
|
# Comprueba que exista el directorio de origen
|
||||||
|
if [ ! -d "$1" ]; then
|
||||||
|
printf "El directorio %s no existe\n" "$1"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Procesa los ficheros
|
||||||
for zipfile in "${sourcedir}"/*.zip; do
|
for zipfile in "${sourcedir}"/*.zip; do
|
||||||
gameName="$(basename "$zipfile" .zip)"
|
gameName="$(basename "$zipfile" .zip)"
|
||||||
|
|
||||||
if [ -f "${destdir}/${gameName}.chd" ]; then
|
if [ -f "${destdir}/${gameName}.chd" ]; then
|
||||||
echo -e "\e[1m\e[41m${gameName}.chd already exists\033[0m"
|
echo -e "\e[1m\e[41m${gameName}.chd already exists\033[0m"
|
||||||
else
|
else
|
||||||
echo -e "\e[1m\e[41mExtracting ${gameName}...\033[0m"
|
echo -e "\e[1m\e[41mExtracting ${gameName}...\033[0m"
|
||||||
@@ -24,9 +36,7 @@ for zipfile in "${sourcedir}"/*.zip; do
|
|||||||
rm -rdf "${destdir}/${gameName}-tmp"
|
rm -rdf "${destdir}/${gameName}-tmp"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### uncomment below to rm the original zip archive
|
# Elimina el fichero
|
||||||
#rm ./"$zipfile"
|
|
||||||
|
|
||||||
if [ "$3" = "-remove" ]; then
|
if [ "$3" = "-remove" ]; then
|
||||||
rm ./"$zipfile"
|
rm ./"$zipfile"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user