Advertisement
mufin_time

[BASH] Rename all files in a folder to numeric counter

Sep 16th, 2023
992
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.37 KB | Software | 0 0
  1. #!/bin/bash
  2. # Place this file (rename.sh) in a different directory
  3. # to the one with your files to be renamed.
  4. # Then run this using relative indexing.
  5. # e.g. If rename.sh is in the parent directory of your files
  6. #      then you run ../rename.sh
  7.  
  8. COUNTER=1
  9. EXT="jpg"
  10. for l in $(ls)
  11. do
  12.         mv $l "$COUNTER.$EXT"
  13.         ((COUNTER = COUNTER + 1))
  14. done
  15. exit 0
  16.  
Tags: BASH rename
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement