Created
May 24, 2024 15:03
-
-
Save dalthonmh/e0866a1c848c06f232a91e72e68819a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
#cambiar nombre archivos | |
#sirve para cambiar el nombre de carpetas de punto a guión: 2024.05.02 a 2024-05-02 | |
#autor: [email protected] fecha: 24/05/2024 | |
# Años a considerar | |
years=("2022" "2023" "2024") | |
# Iterar sobre cada año definido | |
for year in "${years[@]}"; do | |
# Buscar todas las carpetas con el formato AAAA.MM.DD | |
for dir in ${year}.??.??; do | |
if [[ -d "$dir" ]]; then | |
# Extraer el año, mes y día | |
y=$(echo $dir | cut -d'.' -f1) | |
m=$(echo $dir | cut -d'.' -f2) | |
d=$(echo $dir | cut -d'.' -f3) | |
# Crear el nuevo nombre con el formato AAAA-MM-DD | |
new_name="${y}-${m}-${d}" | |
# Renombrar la carpeta | |
mv "$dir" "$new_name" | |
# Confirmación de la renombración | |
echo "Renombrado: $dir -> $new_name" | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment