Skip to content

Instantly share code, notes, and snippets.

@Kelvinson
Created May 5, 2018 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kelvinson/0879c717252d05b6e6f6141f4cf0750f to your computer and use it in GitHub Desktop.
Save Kelvinson/0879c717252d05b6e6f6141f4cf0750f to your computer and use it in GitHub Desktop.
rename the file in the current directory by adding index to the file name
index=1
# ls -rt means list in the order of oldest first
for i in $(ls *.pdf -rt)
do
cp "${i}" "${index}_${i}"
index=$((index+1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment