Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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 used a script that renamed my file eg 'echo webutil.olb | tr [A-Z] [a-z]' i wanted to rename it back to webutil.olb. How do i do this for many other files that i have

share|improve this question
Does the file name literally contain those strings or did you change it from or to upper or lower case and want to change it back? – Dennis Williamson May 11 '10 at 12:33

Debian rename allows you to specify a sed substitution pattern to apply against filenames in order to rename them.

share|improve this answer
if you've installed perl this is often supplied by prename (a version of the classic script), so the transform is perl instead of sed. – quack quixote May 11 '10 at 9:50

Assuming that the files got renamed with the extra strings, this would probably help:

for file in echo*
    new="${file#* }"    # strip up to the first space (remove "echo ")
    new="${new% |*}"    # strip the space-pipe and after (remove " | tr ...")
    mv "$file" "$new"

This will rename, for example, a file named literally "echo webutil.olb | tr [A-Z] [a-z]" to be named "webutil.olb" and will work for other files similarly named. It expects the wanted names to be between a space and a space followed by a pipe.

share|improve this answer

For your example, tr left webutil.olb as it was.

In general, you can't do this, since you lose the information about case. For example, the filename "webutil.olb" might come from applying tr to "WebUtil.olb" or "WEBUTIL.olb".

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .