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

Suppose that, on a UNIX system, I have a directory that contains the files abc.css, abc.js, and abc.html. In the console, is there a command that I can run that will rename the files to xyz.css, xyz.js, and xyz.html, respectively?

The solution that I'm envisioning is some combination of mv and a regular expression, but I'm not sure exactly how to combine the two.

share|improve this question

On Linux the rename command will work:

rename abc xyz "abc.*"

share|improve this answer

What OS?

In Windows you don’t need regular expressions. A simple wildcard should suffice:

>ren abc.* xyz.*
share|improve this answer
    
For some reason, that didn't work for me. It gave me the typical "usage: mv ..." error response that it gives when the command syntax is incorrect. – zeptonaut Feb 13 '12 at 3:58
    
What OS?​​​​​​​ – Synetech Feb 13 '12 at 4:06
    
What? No, that will get expanded to mv abc.css abc.js abc.html xyz.css xyz.js xyz.html. Have you tested this? – Christian Mann Feb 13 '12 at 5:46
    
@ChristianMann, yes I did and it worked as expected in Windows. – Synetech Feb 13 '12 at 6:01
    
mv isn't a command in cmd.exe. Are you in PowerShell, Cygwin, or an SSH connection to a Linux box? – Christian Mann Feb 13 '12 at 7:10

You must log in to answer this question.

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