49 lines
1.2 KiB
Bash
Executable File
49 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Script para copiar ciertas carpetas de Skrapper
|
|
|
|
## Comprueba los parametros
|
|
if [ "$#" -lt 2 ]; then
|
|
printf "Uso: %s SOURCEDIR DESTDIR" "$(basename "$0")"
|
|
exit 0
|
|
else
|
|
readonly ORIGEN="$1"
|
|
readonly DESTINO="$2"
|
|
fi
|
|
|
|
# Comprueba que exista el directorio de origen
|
|
if [ ! -d "$1" ]; then
|
|
printf "El directorio %s no existe\n" "$1"
|
|
exit 0
|
|
fi
|
|
|
|
# Si no existe, crea el directorio de destino
|
|
if [ ! -d "$2" ]; then
|
|
mkdir -p "$2"
|
|
fi
|
|
|
|
# Colores
|
|
WHITE=$(tput setaf 7)
|
|
BLUE_BG=$(tput setab 4)
|
|
LIME_YELLOW=$(tput setaf 190)
|
|
NORMAL=$(tput sgr0)
|
|
BOLD=$(tput bold)
|
|
|
|
MEDIA="cover title screenshot"
|
|
readonly MEDIA
|
|
|
|
mkdir -p "${DESTINO}"
|
|
|
|
for ITEM in "${ORIGEN}"/*; do
|
|
SISTEMA=$(basename "${ITEM}")
|
|
|
|
printf "\n\n%s\n" "${BOLD}${WHITE}${BLUE_BG} ${SISTEMA} ${NORMAL}"
|
|
for CARPETA in $MEDIA; do
|
|
printf "\n%s\n" "${BOLD}${LIME_YELLOW}${CARPETA}${NORMAL}"
|
|
mkdir -p "${DESTINO}/${SISTEMA}/${CARPETA}"
|
|
rsync -avh --delete --chmod=755 "${ITEM}"/"${CARPETA}/" "${DESTINO}/${SISTEMA}/${CARPETA}/"
|
|
rsync -avh --delete --chmod=755 "${ITEM}"/gamelist.xml "${DESTINO}/${SISTEMA}/"
|
|
chown sergio:sergio "${DESTINO}/${SISTEMA}/${CARPETA}/"*
|
|
done
|
|
done
|