[Ilugc] [Tip] Renaming files

  • From: andyetitmoves@xxxxxxxxx (Ramkumar R)
  • Date: Tue Apr 4 17:39:30 2006

for i in *jpg; do mv "$i" "`echo "$i"|sed 's/ /_/g'`"; done

this is perhaps more efficient... not posix compliant though (works on
zsh, bash)

for i in *.jpg; do mv "$i" "${i// /-}"; done

or in true zsh style:

for i (*.jpg) mv "$i" "${i// /-}"

or the rename on a debian box (i used to encounter a diff. rename when
i was on fedora, this is the perl based one)

rename 'y/ /-/' *.jpg

--
April 1: This is the day upon which we are reminded of
what we are on the other three hundred and sixty-four.
          -- Mark Twain, "Pudd'nhead Wilson's Calendar"

Other related posts: