From f4f2333d36aaa3d1436dd68aa68e4710c04009fb Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 18 Dec 2023 11:33:28 +0100 Subject: [PATCH] refs #5576 perf update scripts sh --- storage/image/move.sh | 6 ++++-- storage/image/prod.sh | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/storage/image/move.sh b/storage/image/move.sh index 49f848767..a981eab8f 100644 --- a/storage/image/move.sh +++ b/storage/image/move.sh @@ -1,5 +1,5 @@ #!/bin/bash - +DIR_LEVELS=2 for collection in */ ; do for size in "$collection"*/ ; do for image in "$size"* ; do @@ -7,7 +7,9 @@ for collection in */ ; do fileName=$(basename "$image") imageName="${fileName%.*}" hash=$(echo -n "$imageName" | sha1sum | awk '{print $1}') - path=$(dirname "$image")/${hash:2:2}/${hash:0:2} + first=$(echo "$hash" | cut -c"$inicio"-"$DIR_LEVELS") + second=$(echo "$hash" | cut -c"$DIR_LEVELS"-"$fin") + path=$(dirname "$image")/${first}/${second} mkdir -p $path ln -s "$image" "$fileName" mv $image $path/$fileName diff --git a/storage/image/prod.sh b/storage/image/prod.sh index 52dd6ae6c..9c6ab66c9 100644 --- a/storage/image/prod.sh +++ b/storage/image/prod.sh @@ -1,27 +1,29 @@ #!/bin/bash - +MIN_DIR_LEVELS=0 +DIR_LEVELS=2 +START=1 +END=3 # Directorio que contiene las carpetas con las fotos -directorio_principal=$1 +MAIN_DIR=$1 # Iterar a través de cada carpeta en el directorio principal -for image in "$directorio_principal"/*; do +for image in "$MAIN_DIR"/*; do # Verificar si es un directorio - # if [ -d "$image" ]; then # Iterar a través de cada imagen en la subcarpeta - # for image in "$image"/*.png; do # Verificar si es un archivo if [ -f "$image" ]; then # Obtener el nombre de la imagen fileName=$(basename "$image") imageName="${fileName%.*}" hash=$(echo -n "$imageName" | sha1sum | awk '{print $1}') -echo "$(dirname "$image")/${hash:0:2}/${hash:2:2}" - - path=$(dirname "$image")/${hash:2:2}/${hash:0:2} + first=$(echo "$hash" | cut -c"$START"-"$DIR_LEVELS") + echo "$first" + second=$(echo "$hash" | cut -c"$DIR_LEVELS"-"$END") + echo "$second" + path=$(dirname "$image")/${first}/${second} mkdir -p $path # Crear un enlace simbólico en la carpeta principal mv $image $path/$fileName - ln -s "$image" "$1/$fileName" fi # done