1

Possible Duplicate:
Renaming multiple files (changing extension)

Suppose I have a bunch of files with the extension .x and I want to change them so that they have the extension .y. I know $ mv *.x *.y wouldn't work because I havn't expressed each file to change their respective extensions (that and the command expects *.y to be a directory).

What command should I issue?

oadams
  • 2,335
  • See also: http://unix.stackexchange.com/questions/19654/renaming-multiple-files-changing-extension & http://unix.stackexchange.com/questions/6777/how-to-clean-up-file-extensions – jasonwryan Sep 26 '11 at 01:48

1 Answers1

2

You can use rename to rename files based on a pattern, and one of the examples from the man page is changing the extension of a group of files. It takes the source pattern, modified pattern, and the files to operate on, so in your case:

$ rename .x .y *.x

It changes the first occurrence of .x to .y, so if you happen to have .x anywhere other than the end of the filename it's going to change that first

Michael Mrozek
  • 93,103
  • 40
  • 240
  • 233