removeFirstCharsFromFilenamesInDir.sh 326 B

123456789101112131415161718
  1. #!/bin/sh
  2. if { [ -z "$1" ] || [ "$1" = -h ] || [ "$1" = --help ];}; then
  3. echo "Usage:"
  4. echo " $(basename "$0") [chars_to_remove]"
  5. echo ""
  6. exit
  7. fi
  8. amount=$1
  9. for dir in *; do
  10. cd "$dir" || return
  11. for i in *.*; do
  12. newName=$(echo "$i" | cut -c"$amount"-)
  13. mv -v "$i" "$newName"
  14. done
  15. cd .. || return
  16. done