refs #5576 perf update scripts sh
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Javier Segarra 2023-12-18 11:33:28 +01:00
parent b1d5a62aa5
commit f4f2333d36
2 changed files with 15 additions and 11 deletions

View File

@ -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

View File

@ -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