.png)
Tengo una carpeta con archivos 1.JPG, 2.JPG,..., 12.JPG
¿Existe una expresión para procesar todos los archivos a la vez? Quiero usar un comando JHead, pero creo que existe una solución general.
¡Gracias!
Respuesta1
Si el procesamiento que necesita es algo así como cambiar el nombre de 1.JPG a MiImagen1-320x480.jpg y 2.JPG a MiImagen2-320x480.jpg, etc., si está utilizando el shell Bash, puede cambiar al directorio que contiene el archivos y usar algo como:
i=0; for n in *.JPG; do mv "${n}" "MyPicture${n/.JPG/-320x480.jpg}"; i=$((i+1)); done; echo "Processed ${i} files."
(Todo lo anterior se puede escribir en una línea de comando).
O si desea ponerlo en un script, sería más fácil de leer y comprender en varias líneas:
# reset counter variable if you want to count the number of files processed
i=0
# loop for all files in current working directory that end with ".JPG"
for n in *.JPG
do
# rename (move) each file from the original name (${n} is generally safer than $n)
# to a new name with some text before the original name and then with the end of
# the original name (".JPG") replaced with a new ending
mv "${n}" "MyPicture${n/.JPG/-320x480.jpg}"
# increment the counter variable
i=$((i+1))
done
# display the number of files processed.
echo "Processed ${i} files."
Si el procesamiento que desea es diferente a este, es posible que deba editar su pregunta para proporcionar más detalles.