Batch renaming files The 2019 Stack Overflow Developer Survey Results Are InBatch renaming of filesHow to remove prefix from multiple files in a directoryHow to replace a string in all folder and file namesbatch rename file names including spaces and patternsReplace occurrences of character in filenamesRenaming Files according to Patternbatch rename a few filesAppend to the name of each file in directoryBash Globbing Variable Substitution?Rename multiple file with no extensions?rename directory of images numericBatch renaming files with patternBatch rename files with unknown names and unknown extensionsBatch renaming of filesAdd extension for multiple files, based on their typesBatch renaming of files with ascending numberMoving and renaming hundreds of .jpg files, all named 5003.jpgrenaming files in a folderBatch renaming files from TerminalBatch renaming when the destination file need spaces

What tool would a Roman-age civilization have for the breaking of silver and other metals into dust?

One word riddle: Vowel in the middle

Is bread bad for ducks?

Shouldn't "much" here be used instead of "more"?

What do hard-Brexiteers want with respect to the Irish border?

Did 3000BC Egyptians use meteoric iron weapons?

Multiply Two Integer Polynomials

Landlord wants to switch my lease to a "Land contract" to "get back at the city"

What are the motivations for publishing new editions of an existing textbook, beyond new discoveries in a field?

Should I use my personal e-mail address, or my workplace one, when registering to external websites for work purposes?

Is flight data recorder erased after every flight?

How technical should a Scrum Master be to effectively remove impediments?

Are spiders unable to hurt humans, especially very small spiders?

Are there any other methods to apply to solving simultaneous equations?

Is this app Icon Browser Safe/Legit?

Identify boardgame from Big movie

Can we generate random numbers using irrational numbers like π and e?

Is there a symbol for a right arrow with a square in the middle?

What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?

Why did Acorn's A3000 have red function keys?

The difference between dialogue marks

What is the closest word meaning "respect for time / mindful"

How to manage monthly salary

Are there incongruent pythagorean triangles with the same perimeter and same area?



Batch renaming files



The 2019 Stack Overflow Developer Survey Results Are InBatch renaming of filesHow to remove prefix from multiple files in a directoryHow to replace a string in all folder and file namesbatch rename file names including spaces and patternsReplace occurrences of character in filenamesRenaming Files according to Patternbatch rename a few filesAppend to the name of each file in directoryBash Globbing Variable Substitution?Rename multiple file with no extensions?rename directory of images numericBatch renaming files with patternBatch rename files with unknown names and unknown extensionsBatch renaming of filesAdd extension for multiple files, based on their typesBatch renaming of files with ascending numberMoving and renaming hundreds of .jpg files, all named 5003.jpgrenaming files in a folderBatch renaming files from TerminalBatch renaming when the destination file need spaces



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








140















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?










share|improve this question



















  • 8





    This is one of the top Unix command line FAQs, and I can't find it on this site already, so should we make this Community Wiki?

    – Gilles
    Aug 24 '10 at 0:08






  • 5





    I don't see why. It's a specific question with a verifiable answer.

    – Internet man
    Aug 24 '10 at 0:45






  • 3





    If you're running X it doesn't get much easier than thunar -B *.png for thunar's bulk-rename gui tool.

    – dotjoe
    Aug 25 '10 at 21:26












  • @dotjoe Thanks, Thunar is interesting indeed.

    – Volker Siegel
    Oct 9 '14 at 3:20

















140















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?










share|improve this question



















  • 8





    This is one of the top Unix command line FAQs, and I can't find it on this site already, so should we make this Community Wiki?

    – Gilles
    Aug 24 '10 at 0:08






  • 5





    I don't see why. It's a specific question with a verifiable answer.

    – Internet man
    Aug 24 '10 at 0:45






  • 3





    If you're running X it doesn't get much easier than thunar -B *.png for thunar's bulk-rename gui tool.

    – dotjoe
    Aug 25 '10 at 21:26












  • @dotjoe Thanks, Thunar is interesting indeed.

    – Volker Siegel
    Oct 9 '14 at 3:20













140












140








140


66






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?










share|improve this question
















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?







shell bash rename






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 24 '10 at 0:52







Internet man

















asked Aug 23 '10 at 23:55









Internet manInternet man

1,8233129




1,8233129







  • 8





    This is one of the top Unix command line FAQs, and I can't find it on this site already, so should we make this Community Wiki?

    – Gilles
    Aug 24 '10 at 0:08






  • 5





    I don't see why. It's a specific question with a verifiable answer.

    – Internet man
    Aug 24 '10 at 0:45






  • 3





    If you're running X it doesn't get much easier than thunar -B *.png for thunar's bulk-rename gui tool.

    – dotjoe
    Aug 25 '10 at 21:26












  • @dotjoe Thanks, Thunar is interesting indeed.

    – Volker Siegel
    Oct 9 '14 at 3:20












  • 8





    This is one of the top Unix command line FAQs, and I can't find it on this site already, so should we make this Community Wiki?

    – Gilles
    Aug 24 '10 at 0:08






  • 5





    I don't see why. It's a specific question with a verifiable answer.

    – Internet man
    Aug 24 '10 at 0:45






  • 3





    If you're running X it doesn't get much easier than thunar -B *.png for thunar's bulk-rename gui tool.

    – dotjoe
    Aug 25 '10 at 21:26












  • @dotjoe Thanks, Thunar is interesting indeed.

    – Volker Siegel
    Oct 9 '14 at 3:20







8




8





This is one of the top Unix command line FAQs, and I can't find it on this site already, so should we make this Community Wiki?

– Gilles
Aug 24 '10 at 0:08





This is one of the top Unix command line FAQs, and I can't find it on this site already, so should we make this Community Wiki?

– Gilles
Aug 24 '10 at 0:08




5




5





I don't see why. It's a specific question with a verifiable answer.

– Internet man
Aug 24 '10 at 0:45





I don't see why. It's a specific question with a verifiable answer.

– Internet man
Aug 24 '10 at 0:45




3




3





If you're running X it doesn't get much easier than thunar -B *.png for thunar's bulk-rename gui tool.

– dotjoe
Aug 25 '10 at 21:26






If you're running X it doesn't get much easier than thunar -B *.png for thunar's bulk-rename gui tool.

– dotjoe
Aug 25 '10 at 21:26














@dotjoe Thanks, Thunar is interesting indeed.

– Volker Siegel
Oct 9 '14 at 3:20





@dotjoe Thanks, Thunar is interesting indeed.

– Volker Siegel
Oct 9 '14 at 3:20










14 Answers
14






active

oldest

votes


















94














If you are using Bash or other POSIX-compatible shell:



for f in *.png; do
mv -- "$f" "$f#image"
done





share|improve this answer




















  • 2





    This is one of the parameter substitution methods shown in Mendel Coopers Advanced Bash-scripting guide tldp.org/LDP/abs/html

    – W_Whalley
    Aug 25 '10 at 14:15






  • 1





    @W_Whalley I strongly recommend avoiding that guide, in favor of the Wooledge Bash Guide.

    – Wildcard
    Nov 27 '16 at 17:55











  • @Wildcard: what are your reasons for recommending to avoid the ABS guide?

    – Christian Severin
    Oct 11 '17 at 11:27











  • @ChristianSeverin promotion of bad practices and outright broken code. Check links on my profile page.

    – Wildcard
    Oct 11 '17 at 16:20











  • If you don't know how to adapt this example for different file patterns, you might want to have a look at the Parameter Expansion Section of the guide mentioned above.

    – lex82
    Dec 28 '18 at 21:50


















100














On Debian and derivatives, Perl's rename works similarly to sed like this:



 rename -v 's/image//' *.png


There's also the rename from util-linux that works like this, instead:



 rename image '' *.png





share|improve this answer




















  • 6





    you really should explain that this is a perl programm that might have to be installed and that it takes regular expressions as the argument.

    – user601
    Aug 24 '10 at 0:30











  • Ah, I was not aware of that. I'll give credit to the canonical answer, when I identify it :)

    – Internet man
    Aug 24 '10 at 0:33






  • 5





    This rename program came from a Perl examples distribution. Debian and Ubuntu ship it as /usr/bin/rename. Other Unix variants may not provide it, or may provide a completely different /usr/bin/rename.

    – Gilles
    Aug 24 '10 at 7:17






  • 1





    Some versions of rename take a from to replacement pattern: rename [options] <expression> <replacement> <file>...

    – melds
    Dec 29 '15 at 18:42







  • 1





    If you are using a Debian based system then sudo apt-get install rename, then you can use the rename command. It is sed for filenames.

    – ctrl-alt-delor
    Dec 31 '16 at 17:20


















39














zmv



The zsh shell has a powerful batch rename command called zmv.



First you need to enable the zmv command as follows (this can go into your ~/.zshrc).



autoload zmv


The basic syntax is zmv PATTERN REPLACEMENT. The pattern is a shell glob expression. Parts of the pattern can be surrounded by parentheses. The replacement text can contain $1, $2, etc. to refer to the Nth parenthesised group in the pattern. For example:



zmv 'image(*.png)' '$1'


You can also ask zsh to automatically define $1, $2, etc. to match the wildcard characters in the pattern:



zmv -w 'image*.png' '$1.png'





share|improve this answer




















  • 4





    sweeeeeeeeeeeeeeeeeet. yet another reason i should be learning zsh.

    – ixtmixilix
    Oct 11 '11 at 13:16






  • 1





    @ixtmixilix what's to learn? Just start using it and perhaps add prezto (github.com/sorin-ionescu/prezto) for some extra awesomeness.

    – Gerry
    Aug 15 '12 at 8:09











  • Really cool, as pointed in zmv's man this can be further simplified by adding alias mmv='noglob zmv -W' to: mmv *.c.orig orig/*.c

    – Bretsko
    Aug 29 '17 at 16:10












  • Enabling zmv prezto requires uncommenting the line in your ~/.zpreztorc following # Set the Zsh functions to load (man zshcontrib). giving zstyle ':prezto:load' zfunction 'zargs' 'zmv'

    – Matt Bracewell
    Apr 1 at 21:51


















31














I normally use the nice and simple mmv (man page) utility for this usecase:



$ mmv "image*.png" "#1.png"


will perform your task.



The #1 in the target pattern will be substituted with whatever matches the wildcard in the source pattern. This also works for several wildcards and can be used for example to change the order of parts of filenames. You can also easily do more complicated things like converting lower case to upper case letters.



Make sure to protect the patterns from the shell by quoting.






share|improve this answer

























  • Thanks for pointing out this utility. I found it in Debian, Ubuntu and Cygwin repositories. I had trouble with the man page, but found some web pages and this Stack Overflow question that helped explain how you were using it. stackoverflow.com/questions/417916/how-to-do-a-mass-rename

    – W_Whalley
    Aug 25 '10 at 16:12











  • Thanks, I added some more information to the answer to make it clearer.

    – Marcel Stimberg
    Aug 25 '10 at 19:28






  • 2





    Can't upvote it enough! It's so simple and friendly. Available for OS X in homebrew.

    – Greg Dubicki
    Mar 17 '17 at 9:33


















8














POSIX sh for loop



Uses sed to rename



for i in image*jpg
do
mv -v "$i" "$(echo "$i" | sed -e 's/^./image//' - )"
done





share|improve this answer






























    6














    I like Perl so:



    perl -nlE '$old=$_; s/image//; qx(mv $old $_)'


    You can also use the same pattern for other tasks like copying the files to another directory:



    perl -nlE '$old=$_; s(image)(/path/to/new/dir/); qx(mv $old $_)'





    share|improve this answer


















    • 2





      Or (safer!): rename($old,$_)

      – reinierpost
      Aug 7 '14 at 11:57


















    4














    qmv



    The command qmv from renameutils opens an editor showing a list of filenames with two colums, separated by a tab. Each row shows one of the filenames, the same in both columns. The right column is representing the new names of the files.

    To make changes, edit the names on the right side. In this example, :%s/... or visual block mode are helpful.



    Filenames in your editor



    $ qmv *.png


    In editor:



    image0001.png image0001.png
    image0002.png image0002.png
    image0003.png image0003.png
    ~
    ~
    ~
    ~
    "/tmp/user/1000/qmvxWyVMs" 3L, 93C


    Edit names in right column:

    (Removing the image prefix from all lines using visual block mode)



    image0001.png 0001.png
    image0002.png 0002.png
    image0003.png 0003.png
    ~
    ~
    ~
    ~
    :wq


    Log of renaming:



    image0001.png -> 0001.png
    image0002.png -> 0002.png
    image0003.png -> 0003.png



    (e.g. Ubuntu: apt-get install renameutils)






    share|improve this answer






























      3














      recursive



      easy recurse selecting image*png files, and assumes no need to deal with newline in file names



      find . -name "image*.png" | while read f; do mv -v "$f" "$(echo "$f" | sed -e 's/^./image//' - )"; done


      Safe, can deal with spaces, new lines, backslashes and anything else:



      find . -name "image*.png" | while IFS= read -r f; do 
      mv -v "$f" "$(echo "$f" | sed -e 's/^./image//' - )";
      done





      share|improve this answer






























        1














        POSIX sh using a while loop



        Reading names from find command.



        find . -maxdepth 1 -type f -name 'image*png' | while IFS= read -r f; do
        mv -v "$f" "$(echo "$f" | sed -e 's/^./image//' - )"
        done


        Reading names from a file



        while IFS= read -r f; do mv -v "$f" "$(echo "$f"|sed -e 's/^./image//' - )"; done < flist





        share|improve this answer
































          1














          Using shell brace expansion:



          for N in 0001..1000; do mv "image,$N.png"; done





          share|improve this answer






























            1














            For Windows and linux, this Perl script will do; in this case:



            $ rnm -l 's/^image//' '*.png'


            The script could run recursively under directories and even prepending a count to all of them:



            $ rnm -r 's/^/$counter./' '/.png$/'


            UTF-8 chars are also correctly treated, both in Windows and linux.






            share|improve this answer






























              0














              You can use this tool: rnm (web page)



              For your case the command would be:



              rnm -rs '/^image//' *.png


              You can find more examples/docs here.






              share|improve this answer
































                0














                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:




                Linux has a variety of batch file renaming options but I didn’t see any short-comings in brename that jumped out at me.




                Features:




                • Cross-platform. Supporting Windows, Mac OS X and Linux.


                • Safe. By checking potential conflicts and errors.


                • File filtering. Supporting including and excluding files via regular expression.
                  No need to run commands like find ./ -name "*.html" -exec CMD.


                • Renaming submatch with corresponding value via key-value file.


                • Renaming via ascending integer.


                • Recursively renaming both files and directories.


                • Supporting dry run.


                • Colorful output.

                Command:



                $ brename -f .png -p image
                [INFO] checking: [ ok ] 'image0001.png' -> '0001.png'
                [INFO] checking: [ ok ] 'image0002.png' -> '0002.png'
                [INFO] checking: [ ok ] 'image0003.png' -> '0003.png'
                [INFO] 3 path(s) to be renamed
                [INFO] renamed: 'image0001.png' -> '0001.png'
                [INFO] renamed: 'image0002.png' -> '0002.png'
                [INFO] renamed: 'image0003.png' -> '0003.png'
                [INFO] 3 path(s) renamed





                share|improve this answer
































                  -5














                  ls *png | while read -r f; do f2="`echo $f | sed -e's/image//'`"; mv $f $f2; done






                  share|improve this answer

























                  • Something's not right: "mv: missing destination file operand after 'image0001.png'"

                    – Internet man
                    Aug 24 '10 at 0:06






                  • 3





                    There are many problems with your code. Parsing the output of ls is just calling for trouble. read should be read -r. all variable substitutions should be within double quotes.

                    – Gilles
                    Aug 24 '10 at 0:20











                  • You could write this more effectively as for f in *png; do f2="$(echo "$f" | sed -e 's/image//')"; mv "$f" "$f2"; done. Parsing ls is neither necessary nor a good idea.

                    – kojiro
                    Feb 10 '14 at 4:24









                  protected by Kusalananda Sep 1 '17 at 8:48



                  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?














                  14 Answers
                  14






                  active

                  oldest

                  votes








                  14 Answers
                  14






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  94














                  If you are using Bash or other POSIX-compatible shell:



                  for f in *.png; do
                  mv -- "$f" "$f#image"
                  done





                  share|improve this answer




















                  • 2





                    This is one of the parameter substitution methods shown in Mendel Coopers Advanced Bash-scripting guide tldp.org/LDP/abs/html

                    – W_Whalley
                    Aug 25 '10 at 14:15






                  • 1





                    @W_Whalley I strongly recommend avoiding that guide, in favor of the Wooledge Bash Guide.

                    – Wildcard
                    Nov 27 '16 at 17:55











                  • @Wildcard: what are your reasons for recommending to avoid the ABS guide?

                    – Christian Severin
                    Oct 11 '17 at 11:27











                  • @ChristianSeverin promotion of bad practices and outright broken code. Check links on my profile page.

                    – Wildcard
                    Oct 11 '17 at 16:20











                  • If you don't know how to adapt this example for different file patterns, you might want to have a look at the Parameter Expansion Section of the guide mentioned above.

                    – lex82
                    Dec 28 '18 at 21:50















                  94














                  If you are using Bash or other POSIX-compatible shell:



                  for f in *.png; do
                  mv -- "$f" "$f#image"
                  done





                  share|improve this answer




















                  • 2





                    This is one of the parameter substitution methods shown in Mendel Coopers Advanced Bash-scripting guide tldp.org/LDP/abs/html

                    – W_Whalley
                    Aug 25 '10 at 14:15






                  • 1





                    @W_Whalley I strongly recommend avoiding that guide, in favor of the Wooledge Bash Guide.

                    – Wildcard
                    Nov 27 '16 at 17:55











                  • @Wildcard: what are your reasons for recommending to avoid the ABS guide?

                    – Christian Severin
                    Oct 11 '17 at 11:27











                  • @ChristianSeverin promotion of bad practices and outright broken code. Check links on my profile page.

                    – Wildcard
                    Oct 11 '17 at 16:20











                  • If you don't know how to adapt this example for different file patterns, you might want to have a look at the Parameter Expansion Section of the guide mentioned above.

                    – lex82
                    Dec 28 '18 at 21:50













                  94












                  94








                  94







                  If you are using Bash or other POSIX-compatible shell:



                  for f in *.png; do
                  mv -- "$f" "$f#image"
                  done





                  share|improve this answer















                  If you are using Bash or other POSIX-compatible shell:



                  for f in *.png; do
                  mv -- "$f" "$f#image"
                  done






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Apr 5 at 13:59









                  ilkkachu

                  63.3k10104181




                  63.3k10104181










                  answered Aug 24 '10 at 0:09









                  W_WhalleyW_Whalley

                  1,33996




                  1,33996







                  • 2





                    This is one of the parameter substitution methods shown in Mendel Coopers Advanced Bash-scripting guide tldp.org/LDP/abs/html

                    – W_Whalley
                    Aug 25 '10 at 14:15






                  • 1





                    @W_Whalley I strongly recommend avoiding that guide, in favor of the Wooledge Bash Guide.

                    – Wildcard
                    Nov 27 '16 at 17:55











                  • @Wildcard: what are your reasons for recommending to avoid the ABS guide?

                    – Christian Severin
                    Oct 11 '17 at 11:27











                  • @ChristianSeverin promotion of bad practices and outright broken code. Check links on my profile page.

                    – Wildcard
                    Oct 11 '17 at 16:20











                  • If you don't know how to adapt this example for different file patterns, you might want to have a look at the Parameter Expansion Section of the guide mentioned above.

                    – lex82
                    Dec 28 '18 at 21:50












                  • 2





                    This is one of the parameter substitution methods shown in Mendel Coopers Advanced Bash-scripting guide tldp.org/LDP/abs/html

                    – W_Whalley
                    Aug 25 '10 at 14:15






                  • 1





                    @W_Whalley I strongly recommend avoiding that guide, in favor of the Wooledge Bash Guide.

                    – Wildcard
                    Nov 27 '16 at 17:55











                  • @Wildcard: what are your reasons for recommending to avoid the ABS guide?

                    – Christian Severin
                    Oct 11 '17 at 11:27











                  • @ChristianSeverin promotion of bad practices and outright broken code. Check links on my profile page.

                    – Wildcard
                    Oct 11 '17 at 16:20











                  • If you don't know how to adapt this example for different file patterns, you might want to have a look at the Parameter Expansion Section of the guide mentioned above.

                    – lex82
                    Dec 28 '18 at 21:50







                  2




                  2





                  This is one of the parameter substitution methods shown in Mendel Coopers Advanced Bash-scripting guide tldp.org/LDP/abs/html

                  – W_Whalley
                  Aug 25 '10 at 14:15





                  This is one of the parameter substitution methods shown in Mendel Coopers Advanced Bash-scripting guide tldp.org/LDP/abs/html

                  – W_Whalley
                  Aug 25 '10 at 14:15




                  1




                  1





                  @W_Whalley I strongly recommend avoiding that guide, in favor of the Wooledge Bash Guide.

                  – Wildcard
                  Nov 27 '16 at 17:55





                  @W_Whalley I strongly recommend avoiding that guide, in favor of the Wooledge Bash Guide.

                  – Wildcard
                  Nov 27 '16 at 17:55













                  @Wildcard: what are your reasons for recommending to avoid the ABS guide?

                  – Christian Severin
                  Oct 11 '17 at 11:27





                  @Wildcard: what are your reasons for recommending to avoid the ABS guide?

                  – Christian Severin
                  Oct 11 '17 at 11:27













                  @ChristianSeverin promotion of bad practices and outright broken code. Check links on my profile page.

                  – Wildcard
                  Oct 11 '17 at 16:20





                  @ChristianSeverin promotion of bad practices and outright broken code. Check links on my profile page.

                  – Wildcard
                  Oct 11 '17 at 16:20













                  If you don't know how to adapt this example for different file patterns, you might want to have a look at the Parameter Expansion Section of the guide mentioned above.

                  – lex82
                  Dec 28 '18 at 21:50





                  If you don't know how to adapt this example for different file patterns, you might want to have a look at the Parameter Expansion Section of the guide mentioned above.

                  – lex82
                  Dec 28 '18 at 21:50













                  100














                  On Debian and derivatives, Perl's rename works similarly to sed like this:



                   rename -v 's/image//' *.png


                  There's also the rename from util-linux that works like this, instead:



                   rename image '' *.png





                  share|improve this answer




















                  • 6





                    you really should explain that this is a perl programm that might have to be installed and that it takes regular expressions as the argument.

                    – user601
                    Aug 24 '10 at 0:30











                  • Ah, I was not aware of that. I'll give credit to the canonical answer, when I identify it :)

                    – Internet man
                    Aug 24 '10 at 0:33






                  • 5





                    This rename program came from a Perl examples distribution. Debian and Ubuntu ship it as /usr/bin/rename. Other Unix variants may not provide it, or may provide a completely different /usr/bin/rename.

                    – Gilles
                    Aug 24 '10 at 7:17






                  • 1





                    Some versions of rename take a from to replacement pattern: rename [options] <expression> <replacement> <file>...

                    – melds
                    Dec 29 '15 at 18:42







                  • 1





                    If you are using a Debian based system then sudo apt-get install rename, then you can use the rename command. It is sed for filenames.

                    – ctrl-alt-delor
                    Dec 31 '16 at 17:20















                  100














                  On Debian and derivatives, Perl's rename works similarly to sed like this:



                   rename -v 's/image//' *.png


                  There's also the rename from util-linux that works like this, instead:



                   rename image '' *.png





                  share|improve this answer




















                  • 6





                    you really should explain that this is a perl programm that might have to be installed and that it takes regular expressions as the argument.

                    – user601
                    Aug 24 '10 at 0:30











                  • Ah, I was not aware of that. I'll give credit to the canonical answer, when I identify it :)

                    – Internet man
                    Aug 24 '10 at 0:33






                  • 5





                    This rename program came from a Perl examples distribution. Debian and Ubuntu ship it as /usr/bin/rename. Other Unix variants may not provide it, or may provide a completely different /usr/bin/rename.

                    – Gilles
                    Aug 24 '10 at 7:17






                  • 1





                    Some versions of rename take a from to replacement pattern: rename [options] <expression> <replacement> <file>...

                    – melds
                    Dec 29 '15 at 18:42







                  • 1





                    If you are using a Debian based system then sudo apt-get install rename, then you can use the rename command. It is sed for filenames.

                    – ctrl-alt-delor
                    Dec 31 '16 at 17:20













                  100












                  100








                  100







                  On Debian and derivatives, Perl's rename works similarly to sed like this:



                   rename -v 's/image//' *.png


                  There's also the rename from util-linux that works like this, instead:



                   rename image '' *.png





                  share|improve this answer















                  On Debian and derivatives, Perl's rename works similarly to sed like this:



                   rename -v 's/image//' *.png


                  There's also the rename from util-linux that works like this, instead:



                   rename image '' *.png






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Aug 20 '16 at 13:43









                  don_crissti

                  51.9k15141168




                  51.9k15141168










                  answered Aug 24 '10 at 0:12









                  Internet manInternet man

                  1,8233129




                  1,8233129







                  • 6





                    you really should explain that this is a perl programm that might have to be installed and that it takes regular expressions as the argument.

                    – user601
                    Aug 24 '10 at 0:30











                  • Ah, I was not aware of that. I'll give credit to the canonical answer, when I identify it :)

                    – Internet man
                    Aug 24 '10 at 0:33






                  • 5





                    This rename program came from a Perl examples distribution. Debian and Ubuntu ship it as /usr/bin/rename. Other Unix variants may not provide it, or may provide a completely different /usr/bin/rename.

                    – Gilles
                    Aug 24 '10 at 7:17






                  • 1





                    Some versions of rename take a from to replacement pattern: rename [options] <expression> <replacement> <file>...

                    – melds
                    Dec 29 '15 at 18:42







                  • 1





                    If you are using a Debian based system then sudo apt-get install rename, then you can use the rename command. It is sed for filenames.

                    – ctrl-alt-delor
                    Dec 31 '16 at 17:20












                  • 6





                    you really should explain that this is a perl programm that might have to be installed and that it takes regular expressions as the argument.

                    – user601
                    Aug 24 '10 at 0:30











                  • Ah, I was not aware of that. I'll give credit to the canonical answer, when I identify it :)

                    – Internet man
                    Aug 24 '10 at 0:33






                  • 5





                    This rename program came from a Perl examples distribution. Debian and Ubuntu ship it as /usr/bin/rename. Other Unix variants may not provide it, or may provide a completely different /usr/bin/rename.

                    – Gilles
                    Aug 24 '10 at 7:17






                  • 1





                    Some versions of rename take a from to replacement pattern: rename [options] <expression> <replacement> <file>...

                    – melds
                    Dec 29 '15 at 18:42







                  • 1





                    If you are using a Debian based system then sudo apt-get install rename, then you can use the rename command. It is sed for filenames.

                    – ctrl-alt-delor
                    Dec 31 '16 at 17:20







                  6




                  6





                  you really should explain that this is a perl programm that might have to be installed and that it takes regular expressions as the argument.

                  – user601
                  Aug 24 '10 at 0:30





                  you really should explain that this is a perl programm that might have to be installed and that it takes regular expressions as the argument.

                  – user601
                  Aug 24 '10 at 0:30













                  Ah, I was not aware of that. I'll give credit to the canonical answer, when I identify it :)

                  – Internet man
                  Aug 24 '10 at 0:33





                  Ah, I was not aware of that. I'll give credit to the canonical answer, when I identify it :)

                  – Internet man
                  Aug 24 '10 at 0:33




                  5




                  5





                  This rename program came from a Perl examples distribution. Debian and Ubuntu ship it as /usr/bin/rename. Other Unix variants may not provide it, or may provide a completely different /usr/bin/rename.

                  – Gilles
                  Aug 24 '10 at 7:17





                  This rename program came from a Perl examples distribution. Debian and Ubuntu ship it as /usr/bin/rename. Other Unix variants may not provide it, or may provide a completely different /usr/bin/rename.

                  – Gilles
                  Aug 24 '10 at 7:17




                  1




                  1





                  Some versions of rename take a from to replacement pattern: rename [options] <expression> <replacement> <file>...

                  – melds
                  Dec 29 '15 at 18:42






                  Some versions of rename take a from to replacement pattern: rename [options] <expression> <replacement> <file>...

                  – melds
                  Dec 29 '15 at 18:42





                  1




                  1





                  If you are using a Debian based system then sudo apt-get install rename, then you can use the rename command. It is sed for filenames.

                  – ctrl-alt-delor
                  Dec 31 '16 at 17:20





                  If you are using a Debian based system then sudo apt-get install rename, then you can use the rename command. It is sed for filenames.

                  – ctrl-alt-delor
                  Dec 31 '16 at 17:20











                  39














                  zmv



                  The zsh shell has a powerful batch rename command called zmv.



                  First you need to enable the zmv command as follows (this can go into your ~/.zshrc).



                  autoload zmv


                  The basic syntax is zmv PATTERN REPLACEMENT. The pattern is a shell glob expression. Parts of the pattern can be surrounded by parentheses. The replacement text can contain $1, $2, etc. to refer to the Nth parenthesised group in the pattern. For example:



                  zmv 'image(*.png)' '$1'


                  You can also ask zsh to automatically define $1, $2, etc. to match the wildcard characters in the pattern:



                  zmv -w 'image*.png' '$1.png'





                  share|improve this answer




















                  • 4





                    sweeeeeeeeeeeeeeeeeet. yet another reason i should be learning zsh.

                    – ixtmixilix
                    Oct 11 '11 at 13:16






                  • 1





                    @ixtmixilix what's to learn? Just start using it and perhaps add prezto (github.com/sorin-ionescu/prezto) for some extra awesomeness.

                    – Gerry
                    Aug 15 '12 at 8:09











                  • Really cool, as pointed in zmv's man this can be further simplified by adding alias mmv='noglob zmv -W' to: mmv *.c.orig orig/*.c

                    – Bretsko
                    Aug 29 '17 at 16:10












                  • Enabling zmv prezto requires uncommenting the line in your ~/.zpreztorc following # Set the Zsh functions to load (man zshcontrib). giving zstyle ':prezto:load' zfunction 'zargs' 'zmv'

                    – Matt Bracewell
                    Apr 1 at 21:51















                  39














                  zmv



                  The zsh shell has a powerful batch rename command called zmv.



                  First you need to enable the zmv command as follows (this can go into your ~/.zshrc).



                  autoload zmv


                  The basic syntax is zmv PATTERN REPLACEMENT. The pattern is a shell glob expression. Parts of the pattern can be surrounded by parentheses. The replacement text can contain $1, $2, etc. to refer to the Nth parenthesised group in the pattern. For example:



                  zmv 'image(*.png)' '$1'


                  You can also ask zsh to automatically define $1, $2, etc. to match the wildcard characters in the pattern:



                  zmv -w 'image*.png' '$1.png'





                  share|improve this answer




















                  • 4





                    sweeeeeeeeeeeeeeeeeet. yet another reason i should be learning zsh.

                    – ixtmixilix
                    Oct 11 '11 at 13:16






                  • 1





                    @ixtmixilix what's to learn? Just start using it and perhaps add prezto (github.com/sorin-ionescu/prezto) for some extra awesomeness.

                    – Gerry
                    Aug 15 '12 at 8:09











                  • Really cool, as pointed in zmv's man this can be further simplified by adding alias mmv='noglob zmv -W' to: mmv *.c.orig orig/*.c

                    – Bretsko
                    Aug 29 '17 at 16:10












                  • Enabling zmv prezto requires uncommenting the line in your ~/.zpreztorc following # Set the Zsh functions to load (man zshcontrib). giving zstyle ':prezto:load' zfunction 'zargs' 'zmv'

                    – Matt Bracewell
                    Apr 1 at 21:51













                  39












                  39








                  39







                  zmv



                  The zsh shell has a powerful batch rename command called zmv.



                  First you need to enable the zmv command as follows (this can go into your ~/.zshrc).



                  autoload zmv


                  The basic syntax is zmv PATTERN REPLACEMENT. The pattern is a shell glob expression. Parts of the pattern can be surrounded by parentheses. The replacement text can contain $1, $2, etc. to refer to the Nth parenthesised group in the pattern. For example:



                  zmv 'image(*.png)' '$1'


                  You can also ask zsh to automatically define $1, $2, etc. to match the wildcard characters in the pattern:



                  zmv -w 'image*.png' '$1.png'





                  share|improve this answer















                  zmv



                  The zsh shell has a powerful batch rename command called zmv.



                  First you need to enable the zmv command as follows (this can go into your ~/.zshrc).



                  autoload zmv


                  The basic syntax is zmv PATTERN REPLACEMENT. The pattern is a shell glob expression. Parts of the pattern can be surrounded by parentheses. The replacement text can contain $1, $2, etc. to refer to the Nth parenthesised group in the pattern. For example:



                  zmv 'image(*.png)' '$1'


                  You can also ask zsh to automatically define $1, $2, etc. to match the wildcard characters in the pattern:



                  zmv -w 'image*.png' '$1.png'






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  answered Aug 24 '10 at 0:15


























                  community wiki





                  Gilles








                  • 4





                    sweeeeeeeeeeeeeeeeeet. yet another reason i should be learning zsh.

                    – ixtmixilix
                    Oct 11 '11 at 13:16






                  • 1





                    @ixtmixilix what's to learn? Just start using it and perhaps add prezto (github.com/sorin-ionescu/prezto) for some extra awesomeness.

                    – Gerry
                    Aug 15 '12 at 8:09











                  • Really cool, as pointed in zmv's man this can be further simplified by adding alias mmv='noglob zmv -W' to: mmv *.c.orig orig/*.c

                    – Bretsko
                    Aug 29 '17 at 16:10












                  • Enabling zmv prezto requires uncommenting the line in your ~/.zpreztorc following # Set the Zsh functions to load (man zshcontrib). giving zstyle ':prezto:load' zfunction 'zargs' 'zmv'

                    – Matt Bracewell
                    Apr 1 at 21:51












                  • 4





                    sweeeeeeeeeeeeeeeeeet. yet another reason i should be learning zsh.

                    – ixtmixilix
                    Oct 11 '11 at 13:16






                  • 1





                    @ixtmixilix what's to learn? Just start using it and perhaps add prezto (github.com/sorin-ionescu/prezto) for some extra awesomeness.

                    – Gerry
                    Aug 15 '12 at 8:09











                  • Really cool, as pointed in zmv's man this can be further simplified by adding alias mmv='noglob zmv -W' to: mmv *.c.orig orig/*.c

                    – Bretsko
                    Aug 29 '17 at 16:10












                  • Enabling zmv prezto requires uncommenting the line in your ~/.zpreztorc following # Set the Zsh functions to load (man zshcontrib). giving zstyle ':prezto:load' zfunction 'zargs' 'zmv'

                    – Matt Bracewell
                    Apr 1 at 21:51







                  4




                  4





                  sweeeeeeeeeeeeeeeeeet. yet another reason i should be learning zsh.

                  – ixtmixilix
                  Oct 11 '11 at 13:16





                  sweeeeeeeeeeeeeeeeeet. yet another reason i should be learning zsh.

                  – ixtmixilix
                  Oct 11 '11 at 13:16




                  1




                  1





                  @ixtmixilix what's to learn? Just start using it and perhaps add prezto (github.com/sorin-ionescu/prezto) for some extra awesomeness.

                  – Gerry
                  Aug 15 '12 at 8:09





                  @ixtmixilix what's to learn? Just start using it and perhaps add prezto (github.com/sorin-ionescu/prezto) for some extra awesomeness.

                  – Gerry
                  Aug 15 '12 at 8:09













                  Really cool, as pointed in zmv's man this can be further simplified by adding alias mmv='noglob zmv -W' to: mmv *.c.orig orig/*.c

                  – Bretsko
                  Aug 29 '17 at 16:10






                  Really cool, as pointed in zmv's man this can be further simplified by adding alias mmv='noglob zmv -W' to: mmv *.c.orig orig/*.c

                  – Bretsko
                  Aug 29 '17 at 16:10














                  Enabling zmv prezto requires uncommenting the line in your ~/.zpreztorc following # Set the Zsh functions to load (man zshcontrib). giving zstyle ':prezto:load' zfunction 'zargs' 'zmv'

                  – Matt Bracewell
                  Apr 1 at 21:51





                  Enabling zmv prezto requires uncommenting the line in your ~/.zpreztorc following # Set the Zsh functions to load (man zshcontrib). giving zstyle ':prezto:load' zfunction 'zargs' 'zmv'

                  – Matt Bracewell
                  Apr 1 at 21:51











                  31














                  I normally use the nice and simple mmv (man page) utility for this usecase:



                  $ mmv "image*.png" "#1.png"


                  will perform your task.



                  The #1 in the target pattern will be substituted with whatever matches the wildcard in the source pattern. This also works for several wildcards and can be used for example to change the order of parts of filenames. You can also easily do more complicated things like converting lower case to upper case letters.



                  Make sure to protect the patterns from the shell by quoting.






                  share|improve this answer

























                  • Thanks for pointing out this utility. I found it in Debian, Ubuntu and Cygwin repositories. I had trouble with the man page, but found some web pages and this Stack Overflow question that helped explain how you were using it. stackoverflow.com/questions/417916/how-to-do-a-mass-rename

                    – W_Whalley
                    Aug 25 '10 at 16:12











                  • Thanks, I added some more information to the answer to make it clearer.

                    – Marcel Stimberg
                    Aug 25 '10 at 19:28






                  • 2





                    Can't upvote it enough! It's so simple and friendly. Available for OS X in homebrew.

                    – Greg Dubicki
                    Mar 17 '17 at 9:33















                  31














                  I normally use the nice and simple mmv (man page) utility for this usecase:



                  $ mmv "image*.png" "#1.png"


                  will perform your task.



                  The #1 in the target pattern will be substituted with whatever matches the wildcard in the source pattern. This also works for several wildcards and can be used for example to change the order of parts of filenames. You can also easily do more complicated things like converting lower case to upper case letters.



                  Make sure to protect the patterns from the shell by quoting.






                  share|improve this answer

























                  • Thanks for pointing out this utility. I found it in Debian, Ubuntu and Cygwin repositories. I had trouble with the man page, but found some web pages and this Stack Overflow question that helped explain how you were using it. stackoverflow.com/questions/417916/how-to-do-a-mass-rename

                    – W_Whalley
                    Aug 25 '10 at 16:12











                  • Thanks, I added some more information to the answer to make it clearer.

                    – Marcel Stimberg
                    Aug 25 '10 at 19:28






                  • 2





                    Can't upvote it enough! It's so simple and friendly. Available for OS X in homebrew.

                    – Greg Dubicki
                    Mar 17 '17 at 9:33













                  31












                  31








                  31







                  I normally use the nice and simple mmv (man page) utility for this usecase:



                  $ mmv "image*.png" "#1.png"


                  will perform your task.



                  The #1 in the target pattern will be substituted with whatever matches the wildcard in the source pattern. This also works for several wildcards and can be used for example to change the order of parts of filenames. You can also easily do more complicated things like converting lower case to upper case letters.



                  Make sure to protect the patterns from the shell by quoting.






                  share|improve this answer















                  I normally use the nice and simple mmv (man page) utility for this usecase:



                  $ mmv "image*.png" "#1.png"


                  will perform your task.



                  The #1 in the target pattern will be substituted with whatever matches the wildcard in the source pattern. This also works for several wildcards and can be used for example to change the order of parts of filenames. You can also easily do more complicated things like converting lower case to upper case letters.



                  Make sure to protect the patterns from the shell by quoting.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Aug 21 '16 at 20:04









                  Greg Dubicki

                  15013




                  15013










                  answered Aug 24 '10 at 15:37









                  Marcel StimbergMarcel Stimberg

                  2,9721314




                  2,9721314












                  • Thanks for pointing out this utility. I found it in Debian, Ubuntu and Cygwin repositories. I had trouble with the man page, but found some web pages and this Stack Overflow question that helped explain how you were using it. stackoverflow.com/questions/417916/how-to-do-a-mass-rename

                    – W_Whalley
                    Aug 25 '10 at 16:12











                  • Thanks, I added some more information to the answer to make it clearer.

                    – Marcel Stimberg
                    Aug 25 '10 at 19:28






                  • 2





                    Can't upvote it enough! It's so simple and friendly. Available for OS X in homebrew.

                    – Greg Dubicki
                    Mar 17 '17 at 9:33

















                  • Thanks for pointing out this utility. I found it in Debian, Ubuntu and Cygwin repositories. I had trouble with the man page, but found some web pages and this Stack Overflow question that helped explain how you were using it. stackoverflow.com/questions/417916/how-to-do-a-mass-rename

                    – W_Whalley
                    Aug 25 '10 at 16:12











                  • Thanks, I added some more information to the answer to make it clearer.

                    – Marcel Stimberg
                    Aug 25 '10 at 19:28






                  • 2





                    Can't upvote it enough! It's so simple and friendly. Available for OS X in homebrew.

                    – Greg Dubicki
                    Mar 17 '17 at 9:33
















                  Thanks for pointing out this utility. I found it in Debian, Ubuntu and Cygwin repositories. I had trouble with the man page, but found some web pages and this Stack Overflow question that helped explain how you were using it. stackoverflow.com/questions/417916/how-to-do-a-mass-rename

                  – W_Whalley
                  Aug 25 '10 at 16:12





                  Thanks for pointing out this utility. I found it in Debian, Ubuntu and Cygwin repositories. I had trouble with the man page, but found some web pages and this Stack Overflow question that helped explain how you were using it. stackoverflow.com/questions/417916/how-to-do-a-mass-rename

                  – W_Whalley
                  Aug 25 '10 at 16:12













                  Thanks, I added some more information to the answer to make it clearer.

                  – Marcel Stimberg
                  Aug 25 '10 at 19:28





                  Thanks, I added some more information to the answer to make it clearer.

                  – Marcel Stimberg
                  Aug 25 '10 at 19:28




                  2




                  2





                  Can't upvote it enough! It's so simple and friendly. Available for OS X in homebrew.

                  – Greg Dubicki
                  Mar 17 '17 at 9:33





                  Can't upvote it enough! It's so simple and friendly. Available for OS X in homebrew.

                  – Greg Dubicki
                  Mar 17 '17 at 9:33











                  8














                  POSIX sh for loop



                  Uses sed to rename



                  for i in image*jpg
                  do
                  mv -v "$i" "$(echo "$i" | sed -e 's/^./image//' - )"
                  done





                  share|improve this answer



























                    8














                    POSIX sh for loop



                    Uses sed to rename



                    for i in image*jpg
                    do
                    mv -v "$i" "$(echo "$i" | sed -e 's/^./image//' - )"
                    done





                    share|improve this answer

























                      8












                      8








                      8







                      POSIX sh for loop



                      Uses sed to rename



                      for i in image*jpg
                      do
                      mv -v "$i" "$(echo "$i" | sed -e 's/^./image//' - )"
                      done





                      share|improve this answer













                      POSIX sh for loop



                      Uses sed to rename



                      for i in image*jpg
                      do
                      mv -v "$i" "$(echo "$i" | sed -e 's/^./image//' - )"
                      done






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Feb 10 '14 at 16:45









                      X TianX Tian

                      7,83512237




                      7,83512237





















                          6














                          I like Perl so:



                          perl -nlE '$old=$_; s/image//; qx(mv $old $_)'


                          You can also use the same pattern for other tasks like copying the files to another directory:



                          perl -nlE '$old=$_; s(image)(/path/to/new/dir/); qx(mv $old $_)'





                          share|improve this answer


















                          • 2





                            Or (safer!): rename($old,$_)

                            – reinierpost
                            Aug 7 '14 at 11:57















                          6














                          I like Perl so:



                          perl -nlE '$old=$_; s/image//; qx(mv $old $_)'


                          You can also use the same pattern for other tasks like copying the files to another directory:



                          perl -nlE '$old=$_; s(image)(/path/to/new/dir/); qx(mv $old $_)'





                          share|improve this answer


















                          • 2





                            Or (safer!): rename($old,$_)

                            – reinierpost
                            Aug 7 '14 at 11:57













                          6












                          6








                          6







                          I like Perl so:



                          perl -nlE '$old=$_; s/image//; qx(mv $old $_)'


                          You can also use the same pattern for other tasks like copying the files to another directory:



                          perl -nlE '$old=$_; s(image)(/path/to/new/dir/); qx(mv $old $_)'





                          share|improve this answer













                          I like Perl so:



                          perl -nlE '$old=$_; s/image//; qx(mv $old $_)'


                          You can also use the same pattern for other tasks like copying the files to another directory:



                          perl -nlE '$old=$_; s(image)(/path/to/new/dir/); qx(mv $old $_)'






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Aug 24 '10 at 0:56









                          gvkvgvkv

                          2,3251817




                          2,3251817







                          • 2





                            Or (safer!): rename($old,$_)

                            – reinierpost
                            Aug 7 '14 at 11:57












                          • 2





                            Or (safer!): rename($old,$_)

                            – reinierpost
                            Aug 7 '14 at 11:57







                          2




                          2





                          Or (safer!): rename($old,$_)

                          – reinierpost
                          Aug 7 '14 at 11:57





                          Or (safer!): rename($old,$_)

                          – reinierpost
                          Aug 7 '14 at 11:57











                          4














                          qmv



                          The command qmv from renameutils opens an editor showing a list of filenames with two colums, separated by a tab. Each row shows one of the filenames, the same in both columns. The right column is representing the new names of the files.

                          To make changes, edit the names on the right side. In this example, :%s/... or visual block mode are helpful.



                          Filenames in your editor



                          $ qmv *.png


                          In editor:



                          image0001.png image0001.png
                          image0002.png image0002.png
                          image0003.png image0003.png
                          ~
                          ~
                          ~
                          ~
                          "/tmp/user/1000/qmvxWyVMs" 3L, 93C


                          Edit names in right column:

                          (Removing the image prefix from all lines using visual block mode)



                          image0001.png 0001.png
                          image0002.png 0002.png
                          image0003.png 0003.png
                          ~
                          ~
                          ~
                          ~
                          :wq


                          Log of renaming:



                          image0001.png -> 0001.png
                          image0002.png -> 0002.png
                          image0003.png -> 0003.png



                          (e.g. Ubuntu: apt-get install renameutils)






                          share|improve this answer



























                            4














                            qmv



                            The command qmv from renameutils opens an editor showing a list of filenames with two colums, separated by a tab. Each row shows one of the filenames, the same in both columns. The right column is representing the new names of the files.

                            To make changes, edit the names on the right side. In this example, :%s/... or visual block mode are helpful.



                            Filenames in your editor



                            $ qmv *.png


                            In editor:



                            image0001.png image0001.png
                            image0002.png image0002.png
                            image0003.png image0003.png
                            ~
                            ~
                            ~
                            ~
                            "/tmp/user/1000/qmvxWyVMs" 3L, 93C


                            Edit names in right column:

                            (Removing the image prefix from all lines using visual block mode)



                            image0001.png 0001.png
                            image0002.png 0002.png
                            image0003.png 0003.png
                            ~
                            ~
                            ~
                            ~
                            :wq


                            Log of renaming:



                            image0001.png -> 0001.png
                            image0002.png -> 0002.png
                            image0003.png -> 0003.png



                            (e.g. Ubuntu: apt-get install renameutils)






                            share|improve this answer

























                              4












                              4








                              4







                              qmv



                              The command qmv from renameutils opens an editor showing a list of filenames with two colums, separated by a tab. Each row shows one of the filenames, the same in both columns. The right column is representing the new names of the files.

                              To make changes, edit the names on the right side. In this example, :%s/... or visual block mode are helpful.



                              Filenames in your editor



                              $ qmv *.png


                              In editor:



                              image0001.png image0001.png
                              image0002.png image0002.png
                              image0003.png image0003.png
                              ~
                              ~
                              ~
                              ~
                              "/tmp/user/1000/qmvxWyVMs" 3L, 93C


                              Edit names in right column:

                              (Removing the image prefix from all lines using visual block mode)



                              image0001.png 0001.png
                              image0002.png 0002.png
                              image0003.png 0003.png
                              ~
                              ~
                              ~
                              ~
                              :wq


                              Log of renaming:



                              image0001.png -> 0001.png
                              image0002.png -> 0002.png
                              image0003.png -> 0003.png



                              (e.g. Ubuntu: apt-get install renameutils)






                              share|improve this answer













                              qmv



                              The command qmv from renameutils opens an editor showing a list of filenames with two colums, separated by a tab. Each row shows one of the filenames, the same in both columns. The right column is representing the new names of the files.

                              To make changes, edit the names on the right side. In this example, :%s/... or visual block mode are helpful.



                              Filenames in your editor



                              $ qmv *.png


                              In editor:



                              image0001.png image0001.png
                              image0002.png image0002.png
                              image0003.png image0003.png
                              ~
                              ~
                              ~
                              ~
                              "/tmp/user/1000/qmvxWyVMs" 3L, 93C


                              Edit names in right column:

                              (Removing the image prefix from all lines using visual block mode)



                              image0001.png 0001.png
                              image0002.png 0002.png
                              image0003.png 0003.png
                              ~
                              ~
                              ~
                              ~
                              :wq


                              Log of renaming:



                              image0001.png -> 0001.png
                              image0002.png -> 0002.png
                              image0003.png -> 0003.png



                              (e.g. Ubuntu: apt-get install renameutils)







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Oct 9 '14 at 3:12









                              Volker SiegelVolker Siegel

                              11.1k33361




                              11.1k33361





















                                  3














                                  recursive



                                  easy recurse selecting image*png files, and assumes no need to deal with newline in file names



                                  find . -name "image*.png" | while read f; do mv -v "$f" "$(echo "$f" | sed -e 's/^./image//' - )"; done


                                  Safe, can deal with spaces, new lines, backslashes and anything else:



                                  find . -name "image*.png" | while IFS= read -r f; do 
                                  mv -v "$f" "$(echo "$f" | sed -e 's/^./image//' - )";
                                  done





                                  share|improve this answer



























                                    3














                                    recursive



                                    easy recurse selecting image*png files, and assumes no need to deal with newline in file names



                                    find . -name "image*.png" | while read f; do mv -v "$f" "$(echo "$f" | sed -e 's/^./image//' - )"; done


                                    Safe, can deal with spaces, new lines, backslashes and anything else:



                                    find . -name "image*.png" | while IFS= read -r f; do 
                                    mv -v "$f" "$(echo "$f" | sed -e 's/^./image//' - )";
                                    done





                                    share|improve this answer

























                                      3












                                      3








                                      3







                                      recursive



                                      easy recurse selecting image*png files, and assumes no need to deal with newline in file names



                                      find . -name "image*.png" | while read f; do mv -v "$f" "$(echo "$f" | sed -e 's/^./image//' - )"; done


                                      Safe, can deal with spaces, new lines, backslashes and anything else:



                                      find . -name "image*.png" | while IFS= read -r f; do 
                                      mv -v "$f" "$(echo "$f" | sed -e 's/^./image//' - )";
                                      done





                                      share|improve this answer













                                      recursive



                                      easy recurse selecting image*png files, and assumes no need to deal with newline in file names



                                      find . -name "image*.png" | while read f; do mv -v "$f" "$(echo "$f" | sed -e 's/^./image//' - )"; done


                                      Safe, can deal with spaces, new lines, backslashes and anything else:



                                      find . -name "image*.png" | while IFS= read -r f; do 
                                      mv -v "$f" "$(echo "$f" | sed -e 's/^./image//' - )";
                                      done






                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Feb 10 '14 at 17:53









                                      X TianX Tian

                                      7,83512237




                                      7,83512237





















                                          1














                                          POSIX sh using a while loop



                                          Reading names from find command.



                                          find . -maxdepth 1 -type f -name 'image*png' | while IFS= read -r f; do
                                          mv -v "$f" "$(echo "$f" | sed -e 's/^./image//' - )"
                                          done


                                          Reading names from a file



                                          while IFS= read -r f; do mv -v "$f" "$(echo "$f"|sed -e 's/^./image//' - )"; done < flist





                                          share|improve this answer





























                                            1














                                            POSIX sh using a while loop



                                            Reading names from find command.



                                            find . -maxdepth 1 -type f -name 'image*png' | while IFS= read -r f; do
                                            mv -v "$f" "$(echo "$f" | sed -e 's/^./image//' - )"
                                            done


                                            Reading names from a file



                                            while IFS= read -r f; do mv -v "$f" "$(echo "$f"|sed -e 's/^./image//' - )"; done < flist





                                            share|improve this answer



























                                              1












                                              1








                                              1







                                              POSIX sh using a while loop



                                              Reading names from find command.



                                              find . -maxdepth 1 -type f -name 'image*png' | while IFS= read -r f; do
                                              mv -v "$f" "$(echo "$f" | sed -e 's/^./image//' - )"
                                              done


                                              Reading names from a file



                                              while IFS= read -r f; do mv -v "$f" "$(echo "$f"|sed -e 's/^./image//' - )"; done < flist





                                              share|improve this answer















                                              POSIX sh using a while loop



                                              Reading names from find command.



                                              find . -maxdepth 1 -type f -name 'image*png' | while IFS= read -r f; do
                                              mv -v "$f" "$(echo "$f" | sed -e 's/^./image//' - )"
                                              done


                                              Reading names from a file



                                              while IFS= read -r f; do mv -v "$f" "$(echo "$f"|sed -e 's/^./image//' - )"; done < flist






                                              share|improve this answer














                                              share|improve this answer



                                              share|improve this answer








                                              edited Feb 10 '14 at 17:55

























                                              answered Feb 10 '14 at 16:52









                                              X TianX Tian

                                              7,83512237




                                              7,83512237





















                                                  1














                                                  Using shell brace expansion:



                                                  for N in 0001..1000; do mv "image,$N.png"; done





                                                  share|improve this answer



























                                                    1














                                                    Using shell brace expansion:



                                                    for N in 0001..1000; do mv "image,$N.png"; done





                                                    share|improve this answer

























                                                      1












                                                      1








                                                      1







                                                      Using shell brace expansion:



                                                      for N in 0001..1000; do mv "image,$N.png"; done





                                                      share|improve this answer













                                                      Using shell brace expansion:



                                                      for N in 0001..1000; do mv "image,$N.png"; done






                                                      share|improve this answer












                                                      share|improve this answer



                                                      share|improve this answer










                                                      answered Sep 1 '17 at 9:06









                                                      αғsнιηαғsнιη

                                                      17.2k103069




                                                      17.2k103069





















                                                          1














                                                          For Windows and linux, this Perl script will do; in this case:



                                                          $ rnm -l 's/^image//' '*.png'


                                                          The script could run recursively under directories and even prepending a count to all of them:



                                                          $ rnm -r 's/^/$counter./' '/.png$/'


                                                          UTF-8 chars are also correctly treated, both in Windows and linux.






                                                          share|improve this answer



























                                                            1














                                                            For Windows and linux, this Perl script will do; in this case:



                                                            $ rnm -l 's/^image//' '*.png'


                                                            The script could run recursively under directories and even prepending a count to all of them:



                                                            $ rnm -r 's/^/$counter./' '/.png$/'


                                                            UTF-8 chars are also correctly treated, both in Windows and linux.






                                                            share|improve this answer

























                                                              1












                                                              1








                                                              1







                                                              For Windows and linux, this Perl script will do; in this case:



                                                              $ rnm -l 's/^image//' '*.png'


                                                              The script could run recursively under directories and even prepending a count to all of them:



                                                              $ rnm -r 's/^/$counter./' '/.png$/'


                                                              UTF-8 chars are also correctly treated, both in Windows and linux.






                                                              share|improve this answer













                                                              For Windows and linux, this Perl script will do; in this case:



                                                              $ rnm -l 's/^image//' '*.png'


                                                              The script could run recursively under directories and even prepending a count to all of them:



                                                              $ rnm -r 's/^/$counter./' '/.png$/'


                                                              UTF-8 chars are also correctly treated, both in Windows and linux.







                                                              share|improve this answer












                                                              share|improve this answer



                                                              share|improve this answer










                                                              answered Jul 1 '18 at 0:19









                                                              circulosmeoscirculosmeos

                                                              141113




                                                              141113





















                                                                  0














                                                                  You can use this tool: rnm (web page)



                                                                  For your case the command would be:



                                                                  rnm -rs '/^image//' *.png


                                                                  You can find more examples/docs here.






                                                                  share|improve this answer





























                                                                    0














                                                                    You can use this tool: rnm (web page)



                                                                    For your case the command would be:



                                                                    rnm -rs '/^image//' *.png


                                                                    You can find more examples/docs here.






                                                                    share|improve this answer



























                                                                      0












                                                                      0








                                                                      0







                                                                      You can use this tool: rnm (web page)



                                                                      For your case the command would be:



                                                                      rnm -rs '/^image//' *.png


                                                                      You can find more examples/docs here.






                                                                      share|improve this answer















                                                                      You can use this tool: rnm (web page)



                                                                      For your case the command would be:



                                                                      rnm -rs '/^image//' *.png


                                                                      You can find more examples/docs here.







                                                                      share|improve this answer














                                                                      share|improve this answer



                                                                      share|improve this answer








                                                                      edited Nov 2 '15 at 19:04

























                                                                      answered Oct 15 '15 at 15:32









                                                                      JahidJahid

                                                                      1587




                                                                      1587





















                                                                          0














                                                                          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:




                                                                          Linux has a variety of batch file renaming options but I didn’t see any short-comings in brename that jumped out at me.




                                                                          Features:




                                                                          • Cross-platform. Supporting Windows, Mac OS X and Linux.


                                                                          • Safe. By checking potential conflicts and errors.


                                                                          • File filtering. Supporting including and excluding files via regular expression.
                                                                            No need to run commands like find ./ -name "*.html" -exec CMD.


                                                                          • Renaming submatch with corresponding value via key-value file.


                                                                          • Renaming via ascending integer.


                                                                          • Recursively renaming both files and directories.


                                                                          • Supporting dry run.


                                                                          • Colorful output.

                                                                          Command:



                                                                          $ brename -f .png -p image
                                                                          [INFO] checking: [ ok ] 'image0001.png' -> '0001.png'
                                                                          [INFO] checking: [ ok ] 'image0002.png' -> '0002.png'
                                                                          [INFO] checking: [ ok ] 'image0003.png' -> '0003.png'
                                                                          [INFO] 3 path(s) to be renamed
                                                                          [INFO] renamed: 'image0001.png' -> '0001.png'
                                                                          [INFO] renamed: 'image0002.png' -> '0002.png'
                                                                          [INFO] renamed: 'image0003.png' -> '0003.png'
                                                                          [INFO] 3 path(s) renamed





                                                                          share|improve this answer





























                                                                            0














                                                                            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:




                                                                            Linux has a variety of batch file renaming options but I didn’t see any short-comings in brename that jumped out at me.




                                                                            Features:




                                                                            • Cross-platform. Supporting Windows, Mac OS X and Linux.


                                                                            • Safe. By checking potential conflicts and errors.


                                                                            • File filtering. Supporting including and excluding files via regular expression.
                                                                              No need to run commands like find ./ -name "*.html" -exec CMD.


                                                                            • Renaming submatch with corresponding value via key-value file.


                                                                            • Renaming via ascending integer.


                                                                            • Recursively renaming both files and directories.


                                                                            • Supporting dry run.


                                                                            • Colorful output.

                                                                            Command:



                                                                            $ brename -f .png -p image
                                                                            [INFO] checking: [ ok ] 'image0001.png' -> '0001.png'
                                                                            [INFO] checking: [ ok ] 'image0002.png' -> '0002.png'
                                                                            [INFO] checking: [ ok ] 'image0003.png' -> '0003.png'
                                                                            [INFO] 3 path(s) to be renamed
                                                                            [INFO] renamed: 'image0001.png' -> '0001.png'
                                                                            [INFO] renamed: 'image0002.png' -> '0002.png'
                                                                            [INFO] renamed: 'image0003.png' -> '0003.png'
                                                                            [INFO] 3 path(s) renamed





                                                                            share|improve this answer



























                                                                              0












                                                                              0








                                                                              0







                                                                              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:




                                                                              Linux has a variety of batch file renaming options but I didn’t see any short-comings in brename that jumped out at me.




                                                                              Features:




                                                                              • Cross-platform. Supporting Windows, Mac OS X and Linux.


                                                                              • Safe. By checking potential conflicts and errors.


                                                                              • File filtering. Supporting including and excluding files via regular expression.
                                                                                No need to run commands like find ./ -name "*.html" -exec CMD.


                                                                              • Renaming submatch with corresponding value via key-value file.


                                                                              • Renaming via ascending integer.


                                                                              • Recursively renaming both files and directories.


                                                                              • Supporting dry run.


                                                                              • Colorful output.

                                                                              Command:



                                                                              $ brename -f .png -p image
                                                                              [INFO] checking: [ ok ] 'image0001.png' -> '0001.png'
                                                                              [INFO] checking: [ ok ] 'image0002.png' -> '0002.png'
                                                                              [INFO] checking: [ ok ] 'image0003.png' -> '0003.png'
                                                                              [INFO] 3 path(s) to be renamed
                                                                              [INFO] renamed: 'image0001.png' -> '0001.png'
                                                                              [INFO] renamed: 'image0002.png' -> '0002.png'
                                                                              [INFO] renamed: 'image0003.png' -> '0003.png'
                                                                              [INFO] 3 path(s) renamed





                                                                              share|improve this answer















                                                                              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:




                                                                              Linux has a variety of batch file renaming options but I didn’t see any short-comings in brename that jumped out at me.




                                                                              Features:




                                                                              • Cross-platform. Supporting Windows, Mac OS X and Linux.


                                                                              • Safe. By checking potential conflicts and errors.


                                                                              • File filtering. Supporting including and excluding files via regular expression.
                                                                                No need to run commands like find ./ -name "*.html" -exec CMD.


                                                                              • Renaming submatch with corresponding value via key-value file.


                                                                              • Renaming via ascending integer.


                                                                              • Recursively renaming both files and directories.


                                                                              • Supporting dry run.


                                                                              • Colorful output.

                                                                              Command:



                                                                              $ brename -f .png -p image
                                                                              [INFO] checking: [ ok ] 'image0001.png' -> '0001.png'
                                                                              [INFO] checking: [ ok ] 'image0002.png' -> '0002.png'
                                                                              [INFO] checking: [ ok ] 'image0003.png' -> '0003.png'
                                                                              [INFO] 3 path(s) to be renamed
                                                                              [INFO] renamed: 'image0001.png' -> '0001.png'
                                                                              [INFO] renamed: 'image0002.png' -> '0002.png'
                                                                              [INFO] renamed: 'image0003.png' -> '0003.png'
                                                                              [INFO] 3 path(s) renamed






                                                                              share|improve this answer














                                                                              share|improve this answer



                                                                              share|improve this answer








                                                                              edited Sep 1 '17 at 8:38

























                                                                              answered Sep 1 '17 at 8:25









                                                                              Wei ShenWei Shen

                                                                              11




                                                                              11





















                                                                                  -5














                                                                                  ls *png | while read -r f; do f2="`echo $f | sed -e's/image//'`"; mv $f $f2; done






                                                                                  share|improve this answer

























                                                                                  • Something's not right: "mv: missing destination file operand after 'image0001.png'"

                                                                                    – Internet man
                                                                                    Aug 24 '10 at 0:06






                                                                                  • 3





                                                                                    There are many problems with your code. Parsing the output of ls is just calling for trouble. read should be read -r. all variable substitutions should be within double quotes.

                                                                                    – Gilles
                                                                                    Aug 24 '10 at 0:20











                                                                                  • You could write this more effectively as for f in *png; do f2="$(echo "$f" | sed -e 's/image//')"; mv "$f" "$f2"; done. Parsing ls is neither necessary nor a good idea.

                                                                                    – kojiro
                                                                                    Feb 10 '14 at 4:24















                                                                                  -5














                                                                                  ls *png | while read -r f; do f2="`echo $f | sed -e's/image//'`"; mv $f $f2; done






                                                                                  share|improve this answer

























                                                                                  • Something's not right: "mv: missing destination file operand after 'image0001.png'"

                                                                                    – Internet man
                                                                                    Aug 24 '10 at 0:06






                                                                                  • 3





                                                                                    There are many problems with your code. Parsing the output of ls is just calling for trouble. read should be read -r. all variable substitutions should be within double quotes.

                                                                                    – Gilles
                                                                                    Aug 24 '10 at 0:20











                                                                                  • You could write this more effectively as for f in *png; do f2="$(echo "$f" | sed -e 's/image//')"; mv "$f" "$f2"; done. Parsing ls is neither necessary nor a good idea.

                                                                                    – kojiro
                                                                                    Feb 10 '14 at 4:24













                                                                                  -5












                                                                                  -5








                                                                                  -5







                                                                                  ls *png | while read -r f; do f2="`echo $f | sed -e's/image//'`"; mv $f $f2; done






                                                                                  share|improve this answer















                                                                                  ls *png | while read -r f; do f2="`echo $f | sed -e's/image//'`"; mv $f $f2; done







                                                                                  share|improve this answer














                                                                                  share|improve this answer



                                                                                  share|improve this answer








                                                                                  edited Aug 24 '10 at 1:38

























                                                                                  answered Aug 24 '10 at 0:02









                                                                                  Ivan PIvan P

                                                                                  1174




                                                                                  1174












                                                                                  • Something's not right: "mv: missing destination file operand after 'image0001.png'"

                                                                                    – Internet man
                                                                                    Aug 24 '10 at 0:06






                                                                                  • 3





                                                                                    There are many problems with your code. Parsing the output of ls is just calling for trouble. read should be read -r. all variable substitutions should be within double quotes.

                                                                                    – Gilles
                                                                                    Aug 24 '10 at 0:20











                                                                                  • You could write this more effectively as for f in *png; do f2="$(echo "$f" | sed -e 's/image//')"; mv "$f" "$f2"; done. Parsing ls is neither necessary nor a good idea.

                                                                                    – kojiro
                                                                                    Feb 10 '14 at 4:24

















                                                                                  • Something's not right: "mv: missing destination file operand after 'image0001.png'"

                                                                                    – Internet man
                                                                                    Aug 24 '10 at 0:06






                                                                                  • 3





                                                                                    There are many problems with your code. Parsing the output of ls is just calling for trouble. read should be read -r. all variable substitutions should be within double quotes.

                                                                                    – Gilles
                                                                                    Aug 24 '10 at 0:20











                                                                                  • You could write this more effectively as for f in *png; do f2="$(echo "$f" | sed -e 's/image//')"; mv "$f" "$f2"; done. Parsing ls is neither necessary nor a good idea.

                                                                                    – kojiro
                                                                                    Feb 10 '14 at 4:24
















                                                                                  Something's not right: "mv: missing destination file operand after 'image0001.png'"

                                                                                  – Internet man
                                                                                  Aug 24 '10 at 0:06





                                                                                  Something's not right: "mv: missing destination file operand after 'image0001.png'"

                                                                                  – Internet man
                                                                                  Aug 24 '10 at 0:06




                                                                                  3




                                                                                  3





                                                                                  There are many problems with your code. Parsing the output of ls is just calling for trouble. read should be read -r. all variable substitutions should be within double quotes.

                                                                                  – Gilles
                                                                                  Aug 24 '10 at 0:20





                                                                                  There are many problems with your code. Parsing the output of ls is just calling for trouble. read should be read -r. all variable substitutions should be within double quotes.

                                                                                  – Gilles
                                                                                  Aug 24 '10 at 0:20













                                                                                  You could write this more effectively as for f in *png; do f2="$(echo "$f" | sed -e 's/image//')"; mv "$f" "$f2"; done. Parsing ls is neither necessary nor a good idea.

                                                                                  – kojiro
                                                                                  Feb 10 '14 at 4:24





                                                                                  You could write this more effectively as for f in *png; do f2="$(echo "$f" | sed -e 's/image//')"; mv "$f" "$f2"; done. Parsing ls is neither necessary nor a good idea.

                                                                                  – kojiro
                                                                                  Feb 10 '14 at 4:24





                                                                                  protected by Kusalananda Sep 1 '17 at 8:48



                                                                                  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?



                                                                                  -bash, rename, shell

                                                                                  Popular posts from this blog

                                                                                  Mobil Contents History Mobil brands Former Mobil brands Lukoil transaction Mobil UK Mobil Australia Mobil New Zealand Mobil Greece Mobil in Japan Mobil in Canada Mobil Egypt See also References External links Navigation menuwww.mobil.com"Mobil Corporation"the original"Our Houston campus""Business & Finance: Socony-Vacuum Corp.""Popular Mechanics""Lubrite Technologies""Exxon Mobil campus 'clearly happening'""Toledo Blade - Google News Archive Search""The Lion and the Moose - How 2 Executives Pulled off the Biggest Merger Ever""ExxonMobil Press Release""Lubricants""Archived copy"the original"Mobil 1™ and Mobil Super™ motor oil and synthetic motor oil - Mobil™ Motor Oils""Mobil Delvac""Mobil Industrial website""The State of Competition in Gasoline Marketing: The Effects of Refiner Operations at Retail""Mobil Travel Guide to become Forbes Travel Guide""Hotel Rankings: Forbes Merges with Mobil"the original"Jamieson oil industry history""Mobil news""Caltex pumps for control""Watchdog blocks Caltex bid""Exxon Mobil sells service station network""Mobil Oil New Zealand Limited is New Zealand's oldest oil company, with predecessor companies having first established a presence in the country in 1896""ExxonMobil subsidiaries have a business history in New Zealand stretching back more than 120 years. We are involved in petroleum refining and distribution and the marketing of fuels, lubricants and chemical products""Archived copy"the original"Exxon Mobil to Sell Its Japanese Arm for $3.9 Billion""Gas station merger will end Esso and Mobil's long run in Japan""Esso moves to affiliate itself with PC Optimum, no longer Aeroplan, in loyalty point switch""Mobil brand of gas stations to launch in Canada after deal for 213 Loblaws-owned locations""Mobil Nears Completion of Rebranding 200 Loblaw Gas Stations""Learn about ExxonMobil's operations in Egypt""Petrol and Diesel Service Stations in Egypt - Mobil"Official websiteExxon Mobil corporate websiteMobil Industrial official websiteeeeeeeeDA04275022275790-40000 0001 0860 5061n82045453134887257134887257

                                                                                  Frič See also Navigation menuinternal link

                                                                                  Identify plant with long narrow paired leaves and reddish stems Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?What is this plant with long sharp leaves? Is it a weed?What is this 3ft high, stalky plant, with mid sized narrow leaves?What is this young shrub with opposite ovate, crenate leaves and reddish stems?What is this plant with large broad serrated leaves?Identify this upright branching weed with long leaves and reddish stemsPlease help me identify this bulbous plant with long, broad leaves and white flowersWhat is this small annual with narrow gray/green leaves and rust colored daisy-type flowers?What is this chilli plant?Does anyone know what type of chilli plant this is?Help identify this plant