Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a large list of files in many folders. Some files are causing issues so I need to rename the parentheses to something else , anything else.

I am trying to use these commands to find any and all files with either "(" or ")".

Obviously this wouldn't work:

find . -name *(*

I need to escape the "(" character:

find . -name *\(*


find . -name '*\(*'


find . -name "*\(*"

Neither of the above works.

In the end, I want the following to work:

`find . -name '*.*' -prune -o -exec rename 's/\*/(*$/\OOOO/i' {} +`  

The above should rename any "(" character to 0000 (eg. Document(July).xls would change to Document0000July).xls)


find . -name '*.*' -prune -o -exec rename 's/\*/)*$/\1111/i' {} +

this should rename any ")" character to 1111 (eg. Document0000July).xls would change to Document0000July1111.xls)

any ideas?


share|improve this question

migrated from May 30 '13 at 0:19

This question came from our site for professional and enthusiast programmers.

Why not trying find with a regex?… – Travis Pessetto May 29 '13 at 17:52
up vote 1 down vote accepted

a simple and quite portable solution (but could choke on special filename cases... a more robust one could be cooked up if you have a recent version of GNU xargs and find):

find . \( -name '*(*' -o -name '*)*' \) -print > ze_list
while read a_line ; do 
   echo mv "$a_line" "$(echo "$a_line" | sed -e 's/(/0000/g' -e 's/)/1111/g')" ; 
done < ze_list

Then if you are confident it would do what you want, take out the 'echo'

(don't worry as the shell is hiding the surrounding quotes (") when using echo, but they will be there to ensure "mv" receives 2 arguments only, a source, and a destination.)

the "$(....|....)" is where the replacement appears. The surrounding quotes are important so that the resulting name, even if it contains spaces, will still be considered one (1) argument.

share|improve this answer

Your Answer


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.