3

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.

3

4 Answers 4

2

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.

0
0

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?

1
  • yes, I can mv, but I prefer rename for renaming too many files Commented Aug 10, 2011 at 1:28
0

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?

0

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.