Advertisement
gmendieta

OrganizeByExt

Mar 4th, 2021 (edited)
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.42 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ $# -ne 1 ]
  4. then
  5.     echo Numero de argumentos incorrecto.
  6.     exit 1
  7. fi
  8.  
  9. echo "Procesamos ficheros con extension '$1'."
  10. #Creamos la carpeta si no existe
  11. if [ ! -d "./$1" ]; then
  12.     mkddir "./$1"
  13. fi
  14.  
  15. #Procesamos los ficheros con la extension recibida
  16. contador=0
  17. for fichero in $( ls *.$1 ); do
  18.     cp "$fichero" "./$1/$fichero"
  19.     contador=$[ $contador + 1 ]
  20. done
  21.  
  22. echo "Procesados &contador ficheros."
  23.  
  24.  
  25.  
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement