Skip to main content
Post Closed as "Duplicate" by Gilles 'SO- stop being evil', slm, jasonwryan, Renan, Anthon
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k
Tweeted twitter.com/#!/StackUnix/status/432599309859962880
added 84 characters in body
Source Link
X Tian
  • 10.7k
  • 3
  • 35
  • 51

I have a directory full of images:

DSCN4749.JPG
DSCN4750.JPG
DSCN4892.JPG
...

And I would like a one-liner to rename them to (say).

dscn4749.jpg
dscn4750.jpg
dscn4892.jpg
...

How do I do this?

Alternatives/extenstions/caveats

  • I want to recurse
  • The directory contains a mix of file types I only want to rename DSCN*.JPG files.
  • bash solution
  • perl solution
  • zsh solution
  • I want a new directory tree with hard links existing files.
  • I want to change name more than just a case change eg dscn5555.JPG to 05555.jpg

...

I have a directory full of images:

DSCN4749.JPG
DSCN4750.JPG
DSCN4892.JPG
...

And I would like a one-liner to rename them to (say).

dscn4749.jpg
dscn4750.jpg
dscn4892.jpg
...

How do I do this?

Alternatives/extenstions/caveats

  • I want to recurse
  • The directory contains a mix of file types I only want to rename DSCN*.JPG files.
  • bash solution
  • perl solution
  • zsh solution
  • I want a new directory tree with hard links existing files.

...

I have a directory full of images:

DSCN4749.JPG
DSCN4750.JPG
DSCN4892.JPG
...

And I would like a one-liner to rename them to (say).

dscn4749.jpg
dscn4750.jpg
dscn4892.jpg
...

How do I do this?

Alternatives/extenstions/caveats

  • I want to recurse
  • The directory contains a mix of file types I only want to rename DSCN*.JPG files.
  • bash solution
  • perl solution
  • zsh solution
  • I want a new directory tree with hard links existing files.
  • I want to change name more than just a case change eg dscn5555.JPG to 05555.jpg

...

Source Link
X Tian
  • 10.7k
  • 3
  • 35
  • 51

Batch renaming of files

I have a directory full of images:

DSCN4749.JPG
DSCN4750.JPG
DSCN4892.JPG
...

And I would like a one-liner to rename them to (say).

dscn4749.jpg
dscn4750.jpg
dscn4892.jpg
...

How do I do this?

Alternatives/extenstions/caveats

  • I want to recurse
  • The directory contains a mix of file types I only want to rename DSCN*.JPG files.
  • bash solution
  • perl solution
  • zsh solution
  • I want a new directory tree with hard links existing files.

...