[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: filename manipulation



On Thu, Feb 17, 2005 at 11:16:27AM -0500, jeff elkins wrote:
   > 
   > I need a shell script to strip X leading characters from a filename. I'm using 
   > basename to change extensions, any analog of this I could use?
   > 
   > #!/bin/sh
   > #
   >   for i in *.zzz; do
   >      if test -f $i; then
   >          NAME=$(basename $i .zzz)  
   >          echo $NAME
   >          mv ${NAME}.zzz ${NAME}.xxx
   >  fi
   >  done
   > 
If you are not very specific about a shell script, give mmv a look.
apt-get install mmv. It is a very useful utility to bulk rename the files.
If I understand the above problem correctly, it would be easy with mmv
to do mmv "*.zzz" "#1.xxx"

HTH,

-- 
Sridhar M.A.                                 GPG KeyID : F6A35935
  Fingerprint: D172 22C4 7CDC D9CD 62B5  55C1 2A69 D5D8 F6A3 5935

Adore, v.:
	To venerate expectantly.
		-- Ambrose Bierce, "The Devil's Dictionary"

Attachment: signature.asc
Description: Digital signature


Reply to: