Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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

Your Answer

 
discard

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.