[NTLUG:Discuss] remove apostrophe from filenames

Robert Citek robert.citek at gmail.com
Sun Jul 29 22:43:09 CDT 2007


On 07/29/2007 09:47 PM, Robert Citek wrote:
> On 07/29/2007 04:56 PM, Mike LaPlante wrote:
>> Can someone give me a quick script check for and remove apostrophes from 
>> a ton of filenames. Doesn't have to be recursive, but won't hurt if it is.
>>
>> I've been trying a very some simple "for" loops involving tr -d "'" but 
>> I'm having trouble.
> 
> Assuming you're using bash, here's a sample:
> 
> $ touch a "a'b" "a b"
> ...
> $ find . -name "*'*" | while read name ; do
>   mv "$name" "${name/\'/}"; done

Or more complete:

touch a "a'b" "a b" "a'b'c"
ls -1
find . -name "*'*" | while read name ; do
  mv "$name" "${name//\'/}"
done
ls -1

Regards,
- Robert



More information about the Discuss mailing list