Skip to content

Instantly share code, notes, and snippets.

@guillorrr
Created October 22, 2023 23:00
Show Gist options
  • Select an option

  • Save guillorrr/2561fb5ee8db52c82ea9a9a2ba4a586a to your computer and use it in GitHub Desktop.

Select an option

Save guillorrr/2561fb5ee8db52c82ea9a9a2ba4a586a to your computer and use it in GitHub Desktop.
Bash scripts
#!/bin/bash
# Leer los archivos de listado a.txt y b.txt en dos arrays
mapfile -t listado_a < old.txt
mapfile -t listado_b < new.txt
# Verificar si los tamaños de los listados son iguales
if [ ${#listado_a[@]} -ne ${#listado_b[@]} ]; then
echo "Los tamaños de los listados no coinciden."
exit 1
fi
# Renombrar los videos en base a los listados
for ((i=0; i<${#listado_a[@]}; i++)); do
old_name="${listado_a[i]}"
new_name="${listado_b[i]}"
mv "$old_name" "$new_name"
echo "Archivo $old_name renombrado como $new_name"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment