Re: mv multiple files w/wildcard
On Sat, Oct 21, 2000 at 01:20:02PM -0500, Lance Hoffmeyer wrote:
>
> I have a number of subdirectories where I have files with - such as
> name - title.txt and I wish to convert them to:
> name: title.txt
>
> In bash I tried:
>
> for i in *-*;do mv $i `echo $i | sed -e 's/ - /:/'`'done
>
> but this gives me an error about moving multiple files and needing a directory
>
>
> I also tried on e-line perl script
>
> perl -we '($new=$_) =~tr/\s-\s/:\s/ && rename _$,$new'
>
> but I get uninitialized value errors. Any help on either of these methods to
> rename files would be appreciated. Also, how would I use these for multiple subdirectories at once?
Look at 'rename':
rename 's/\s-\s/: /' *
(Note that you don't want \s in the right hand side of a s///, it won't
put a space in like you seem to think... it will put in the letter 's'.)
--
CueCat decoder .signature by Larry Wall:
#!/usr/bin/perl -n
printf "Serial: %s Type: %s Code: %s\n", map { tr/a-zA-Z0-9+-/ -_/; $_ = unpack
'u', chr(32 + length()*3/4) . $_; s/\0+$//; $_ ^= "C" x length; } /\.([^.]+)/g;
Reply to: