Re removing hyphens from filenames

Fred Youhanaie fly at anydata.co.uk
Thu Jul 12 13:43:01 BST 2007


Matt Wilson wrote:
> On 7/12/07, Abigail <abigail at abigail.be> wrote:
>> for f in `find . -name '*-*'`; do mv $f `echo $f | tr -d -`; done
> 
> I generally avoid the use of `for' in operations such as this - you
> never know when people have created files with spaces in the name.
> 

not only that, `find ...` may a return a list far too large for the 
shell to handle!

	find ... | while read f; do ... done

Of course you also need to take care of cases such as 'a-bc' and 'ab-c', 
both map to abc :(

	... mv -i "$f" ...

Cheers
f.



More information about the london.pm mailing list