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 bunch of files (around 900) that have some special characters.

Some of the files contains example, and quoting "[useless] filename (something)" so what I want is just to strip the brackets and parenthesis, some are folders, others are text files

share|improve this question
up vote 2 down vote accepted

Debian comes with a program called prename which can rename files using regexes:

prename 's/^\[.+?\] *//; s/ \(.+?\)$//' *
share|improve this answer
Use -v for verbose and -n to preview the results (and do nothing). This way you can check the result first. – Geoff Mar 23 '11 at 19:50
thanks a lot you two :) – allenskd Mar 23 '11 at 22:51
sorry, my regex skill sucks so I ask.. there are some files with brackets parenthesis on both sides, but that code only removes the starting line :( – allenskd Mar 24 '11 at 21:10

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.