Thursday, June 27, 2013

bash: Batch File Rename with Sequential Index

$ c=1; for i in *.JPG; do mv -i "${i}" "IMG`printf "%05d" ${c}`.jpg"; c=$((c+1)); done
source Pattern matching

If you have PrefixFileFooBar.txt and want FooBar.txt

for f in $(ls); do echo "${f##PrefixFile}"; done

No comments:

Post a Comment