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.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityI'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.
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.
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
?
mv
, but I prefer rename
for renaming too many files
Aug 10, 2011 at 1:28
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?
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.