I have a directory full of images:
image0001.png
image0002.png
image0003.png
...
And I would like a one-liner to rename them to (say).
0001.png
0002.png
0003.png
...
How do I do this?
|
If you are using
|
|||||||||||||||||||||
|
|
On Debian and derivatives, Perl's
There's also the
|
|||||||||||||||||||||
|
zmvThe zsh shell has a powerful batch rename command called First you need to enable the
The basic syntax is
You can also ask zsh to automatically define
|
|||||||||||||
|
|
I normally use the nice and simple mmv (man page) utility for this usecase:
will perform your task. The Make sure to protect the patterns from the shell by quoting. |
|||||||||||||
|
POSIX sh for loopUses sed to rename
|
|||||
|
|
I like Perl so:
You can also use the same pattern for other tasks like copying the files to another directory:
|
|||||
|
recursiveeasy recurse selecting image*png files, and assumes no need to deal with newline in file names
Safe, can deal with spaces, new lines, backslashes and anything else:
|
|||
|
|
qmvThe command Filenames in your editor
In editor:
Edit names in right column:
Log of renaming:
(e.g. Ubuntu: |
|||
|
|
POSIX sh using a while loopReading names from
Reading names from a file
|
||||
|
|
|
You can use this tool: rnm (web page) For your case the command would be:
You can find more examples/docs here. |
||||
|
|
|
Try brename (https://github.com/shenwei356/brename), a practical cross-platform command-line tool for safely batch renaming files/directories via regular expression (supporting Windows, Linux and OS X) . @patrickDurusau said:
Features:
Command:
|
||||
|
|
|
Using shell brace expansion:
|
|||
|
|
|
ls *png | while read -r f; do f2="`echo $f | sed -e's/image//'`"; mv $f $f2; done |
|||||||||||||
|
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
thunar -B *.pngfor thunar's bulk-rename gui tool. – dotjoe Aug 25 '10 at 21:26