[Mageia-discuss] Debian-style «rename» utility?

Renaud (Ron) Olgiati renaud at olgiati-in-paraguay.org
Wed Jan 2 11:24:22 CET 2013


On Tuesday 01 Jan 2013 21:13 my mailbox was graced by a message from Renaud 
(Ron) Olgiati who wrote:
> I have been removing spaces and a number of characters that cause problems
> in  filenames with the following:
> 
> #!/bin/bash
> ls | grep " " >totototo
> while [ -s totototo ]
> do
> rename " " _ *" "*
> ls | grep " " >totototo
> done
> for CHR in "(" ")" "," "%" "'" ":" ";" "__" "_-"
> do
> ls | grep $CHR >totototo
> while [ -s totototo ]
> do
> rename $CHR "" *$CHR*
> ls | grep $CHR >totototo
> done
> rm -f totototo
> done
> echo "Finished !"
> 
> Forgot why the space character is treated apart from the others, but ISTR
> that  the for would not work if $CHR was a space.
  
It came back ! It is because the spaces are replaced by an _ while the 
characters, or groups of characters, in the "for CHR in..." line are simply 
removed.
 
Cheers,
 
Ron.
-- 
             Les vieux donnent de bons conseils pour se consoler
                de ne plus pouvoir donner le mauvais exemple.
                                             -- La Rochefoucauld 
                                    
                   -- http://www.olgiati-in-paraguay.org --
 



More information about the Mageia-discuss mailing list