Advertisement
cd62131

rename

Jul 17th, 2018
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.30 KB | None | 0 0
  1. #!/bin/bash
  2. # chmod +x this_script.sh
  3. # usage: ./this_script *.txt
  4. for name in "$@"; do
  5.   new=$(sed -r 's/^[^0-9]+/xxx/' <<<"${name}")
  6.   if [[ -e "${new}" ]]; then
  7.     echo "$0: ${new} already exists." >&2
  8.     continue
  9.   fi
  10.   # remove 'echo' --> rename actually
  11.   echo mv -v "${name}" "${new}"
  12. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement