Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm trying to rename rename character â of directory name to be blank. For example, directory with name how-â8093-to.

This is the command I use, including some other modification

find . -type d | xargs rename 's/â//'

but still not works.

share|improve this question
    
any error message? –  Stéphane Gimenez Aug 10 '11 at 0:27
    
no error message, but it simply do nothing –  Najib-botak Chin Aug 10 '11 at 0:51
    
Related question: bulk rename files with special characters. –  Stéphane Gimenez Aug 12 '11 at 11:28
add comment

4 Answers 4

When using find to operate on files you should always try to use the -exec function rather than xargs wherever possible because it will side-step a lot of potential issues with argument quoting. Particularly in the case of file names with weird characters, this is very important.

Try the following command:

find . -type d -name '*â*' -execdir rename 'â' '' {} \;

This will find everything just the way you were before except it will use find to also filter by name for only files that have â in the name (since it would be pointless to run the rename command on non-matching files) and then run rename on them each individually from the directory where they are found.

share|improve this answer
    
+1 for -exec! –  janmoesen Oct 15 '11 at 20:07
add comment

Are you just trying to remove that character from one file and can't do it? Can you type mv how-tabhow-8093-to or mv how-?8093-to how-8093-to?

share|improve this answer
    
yes, I can mv, but I prefer rename for renaming too many files –  Najib-botak Chin Aug 10 '11 at 1:28
add comment

You can try to work-around using complement character classes, e.g.:

find . -type d | xargs rename 's/[^A-Za-z0-9 ]//'

However, on a Ubuntu 10.04 system I can't reproduce your issue with your example filename and rename. Perhaps something is wrong with your perl installation or locales?

share|improve this answer
add comment

I do not know how version of rename (I am using util-linux version) are you using but on my Fedora 15 works with:

rename 'â' '' how-â8093-to

From rename manual:

NAME
   rename - Rename files

SYNOPSIS
       rename from to file...
       rename -V

DESCRIPTION
       rename will rename the specified files by replacing the first occurrence of from in their name by to.

I cannot read anything about the sed like syntax you are using.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.