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

Re: replace chars in filenames?



Here's a csh hack for doing this. I didn't write it (csh? ugh) 
it but I do use it from time to time. 
<disclaimer>Maybe test it first to make sure it does 
what you want</disclaimer>. -chris

#!/bin/csh -f
# Performs search & replace on the given files

if ( $#argv < 3 ) then
	echo "Usage: replace <string> <with> <file-list>"
	exit 0
endif

if ( $#argv == 2 ) then
	sed "s/$1/$2/g"
	exit 0

endif


set list=($argv[3-])
set list=`grep -l $1 $list`

mkdir replace.back


foreach file ( $list )
	echo "Replacing in: $file"
	cp -f $file $file.back
	cat $file.back | sed "s/$1/$2/g" >! $file
	mv -f $file.back replace.back	
	rm -f $file.back
end

echo "DONE."



On Sun, 10 Sep 2000, Lars Grobe wrote:

> Hi!
> 
> As I have had trouble with netatalk's character set, I have many
> filenames containing nonsense-chars (resulting from non-translated
> German Umlaute). So I have to find strings as :8a and replace them
> with a char (ä). Is it possible to do this with "find" ?
> 
> Thank You, CU, Lars.
> 
> -- 
> Sent through GMX FreeMail - http://www.gmx.net
> 
> 
> -- 
> Unsubscribe?  mail -s unsubscribe debian-user-request@lists.debian.org < /dev/null
> 



Reply to: