Rename multiple files with 2 conditions/replacements in one line?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





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







up vote
8
down vote

favorite












I'm trying to rename a few images:



IMG_1.JPG
IMG_2.JPG
IMG_3.JPG


I want to replace IMG with img and .JPG with .jpg - I know how to do the second part:



$ rename 's/.JPG$/.jpg/' *.JPG


My problem is that I can't seem to mv IMG_.JPG to img_.jpg - I know you can pass multiple patterns to rename, but I can't seem to use the existing filename with an amended lowercase value.



How do I go about this?







share|improve this question



























    up vote
    8
    down vote

    favorite












    I'm trying to rename a few images:



    IMG_1.JPG
    IMG_2.JPG
    IMG_3.JPG


    I want to replace IMG with img and .JPG with .jpg - I know how to do the second part:



    $ rename 's/.JPG$/.jpg/' *.JPG


    My problem is that I can't seem to mv IMG_.JPG to img_.jpg - I know you can pass multiple patterns to rename, but I can't seem to use the existing filename with an amended lowercase value.



    How do I go about this?







    share|improve this question























      up vote
      8
      down vote

      favorite









      up vote
      8
      down vote

      favorite











      I'm trying to rename a few images:



      IMG_1.JPG
      IMG_2.JPG
      IMG_3.JPG


      I want to replace IMG with img and .JPG with .jpg - I know how to do the second part:



      $ rename 's/.JPG$/.jpg/' *.JPG


      My problem is that I can't seem to mv IMG_.JPG to img_.jpg - I know you can pass multiple patterns to rename, but I can't seem to use the existing filename with an amended lowercase value.



      How do I go about this?







      share|improve this question













      I'm trying to rename a few images:



      IMG_1.JPG
      IMG_2.JPG
      IMG_3.JPG


      I want to replace IMG with img and .JPG with .jpg - I know how to do the second part:



      $ rename 's/.JPG$/.jpg/' *.JPG


      My problem is that I can't seem to mv IMG_.JPG to img_.jpg - I know you can pass multiple patterns to rename, but I can't seem to use the existing filename with an amended lowercase value.



      How do I go about this?









      share|improve this question












      share|improve this question




      share|improve this question








      edited Jul 27 at 20:03









      Jesse_b

      10.1k12658




      10.1k12658









      asked Jul 27 at 13:15









      ThisGuyHasTwoThumbs

      1708




      1708




















          4 Answers
          4






          active

          oldest

          votes

















          up vote
          10
          down vote



          accepted










          Maybe you need to be using the perl rename command. On my CentOS box, it's called 'prename'.



          $ ls
          IMG_1.JPG IMG_2.JPG IMG_3.JPG
          $ prename 's/^IMG/img/;s/.JPG$/.jpg/' *JPG
          $ ls
          img_1.jpg img_2.jpg img_3.jpg
          $

          $ prename -h
          Usage: prename [OPTION]... PERLEXPR FILE...
          Rename FILE(s) using PERLEXPR on each filename.

          -b, --backup make backup before removal
          -B, --prefix=SUFFIX set backup filename prefix
          -f, --force remove existing destinations, never prompt
          -i, --interactive prompt before overwrite
          -l, --link-only link file instead of reame
          -n, --just-print, --dry-run don't rename, implies --verbose
          -v, --verbose explain what is being done
          -V, --version-control=METHOD override the usual version control
          -Y, --basename-prefix=PREFIX set backup filename basename prefix
          -z, -S, --suffix=SUFFIX set backup filename suffix
          --help display this help and exit
          --version output version information and exit

          The backup suffix is ~, unless set with SIMPLE_BACKUP_SUFFIX. The
          version control may be set with VERSION_CONTROL, values are:

          numbered, t make numbered backups
          existing, nil numbered if numbered backups exist, simple otherwise
          simple, never always make simple backups

          Report bugs to pederst@cpan.org
          $


          If you want to use the dumb rename command from util-linux (sometimes called rename.ul), perhaps needs doing in two steps, e.g.



          $ ls
          IMG_1.JPG IMG_2.JPG IMG_3.JPG
          $ rename IMG img *JPG
          $ rename JPG jpg *JPG
          $ ls
          img_1.jpg img_2.jpg img_3.jpg
          $





          share|improve this answer



















          • 3




            Note that the perl rename predates the dumb rename found in util-linux that you call plain old rename. It even predates Linux.
            – Stéphane Chazelas
            Jul 27 at 14:49











          • Thanks, didnt realise that, revised
            – steve
            Jul 27 at 14:52

















          up vote
          5
          down vote













          To answer you question in the generic,




          rename multiple files with 2 conditions/replacements in one line?




          you would typically use capture groups, referring to them in the replacement expression using their corresponding backreferences. For example



          $ rename -n 's/^(.*)_(.*).JPG$/L$1_$2.jpg/' *.JPG
          rename(IMG_2.JPG, img_2.jpg)
          rename(IMG_3.JPG, img_3.jpg)


          However, in this particular case, it would be simpler to just apply the lowercase modifier L to the whole name:



          $ rename -n 's/.*/L$&/' *.JPG
          rename(IMG_2.JPG, img_2.jpg)
          rename(IMG_3.JPG, img_3.jpg)


          Another alternative, using mmv



          $ mmv -n '*.JPG' '#l1.jpg'
          IMG_2.JPG -> img_2.jpg
          IMG_3.JPG -> img_3.jpg


          (remove the -n to actually perform the rename).






          share|improve this answer























          • Or zmv's: zmv '*.JPG' '$(L)f'
            – Stéphane Chazelas
            Jul 27 at 15:00






          • 1




            A simpler version of rename 's/.*/L$&/' *.JPG would be rename '$_ = lc' *.JPG
            – hobbs
            Jul 27 at 17:04

















          up vote
          2
          down vote













          Using mv:



          sh compatible:



          for file in *.JPG; do mv "$file" "$(echo "$file" | tr '[:upper:]' '[:lower:]')"; done


          bash (Thanks steeldriver):



          for file in *.JPG; do mv "$file" "$file,,"; done


          This will loop through all .JPG files in the current directory and rename them to the same name with all uppercase characters converted to lowercase characters.






          share|improve this answer






























            up vote
            1
            down vote













            The simplest way and based on the man page that does not cover a regular expression:



            rename 'IMG' 'img' * ; rename 'JPG' 'jpg' *





            share|improve this answer























            • IMHO, a simple answer like this achieves what the heavy hitting occasionally fails to. No malice towards seasoned programmers, but since the question seems to be from a newbie, simplicity needs to be encouraged.
              – Hopping Bunny
              Aug 1 at 6:04










            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );








             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f458839%2frename-multiple-files-with-2-conditions-replacements-in-one-line%23new-answer', 'question_page');

            );

            Post as a guest






























            4 Answers
            4






            active

            oldest

            votes








            4 Answers
            4






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            10
            down vote



            accepted










            Maybe you need to be using the perl rename command. On my CentOS box, it's called 'prename'.



            $ ls
            IMG_1.JPG IMG_2.JPG IMG_3.JPG
            $ prename 's/^IMG/img/;s/.JPG$/.jpg/' *JPG
            $ ls
            img_1.jpg img_2.jpg img_3.jpg
            $

            $ prename -h
            Usage: prename [OPTION]... PERLEXPR FILE...
            Rename FILE(s) using PERLEXPR on each filename.

            -b, --backup make backup before removal
            -B, --prefix=SUFFIX set backup filename prefix
            -f, --force remove existing destinations, never prompt
            -i, --interactive prompt before overwrite
            -l, --link-only link file instead of reame
            -n, --just-print, --dry-run don't rename, implies --verbose
            -v, --verbose explain what is being done
            -V, --version-control=METHOD override the usual version control
            -Y, --basename-prefix=PREFIX set backup filename basename prefix
            -z, -S, --suffix=SUFFIX set backup filename suffix
            --help display this help and exit
            --version output version information and exit

            The backup suffix is ~, unless set with SIMPLE_BACKUP_SUFFIX. The
            version control may be set with VERSION_CONTROL, values are:

            numbered, t make numbered backups
            existing, nil numbered if numbered backups exist, simple otherwise
            simple, never always make simple backups

            Report bugs to pederst@cpan.org
            $


            If you want to use the dumb rename command from util-linux (sometimes called rename.ul), perhaps needs doing in two steps, e.g.



            $ ls
            IMG_1.JPG IMG_2.JPG IMG_3.JPG
            $ rename IMG img *JPG
            $ rename JPG jpg *JPG
            $ ls
            img_1.jpg img_2.jpg img_3.jpg
            $





            share|improve this answer



















            • 3




              Note that the perl rename predates the dumb rename found in util-linux that you call plain old rename. It even predates Linux.
              – Stéphane Chazelas
              Jul 27 at 14:49











            • Thanks, didnt realise that, revised
              – steve
              Jul 27 at 14:52














            up vote
            10
            down vote



            accepted










            Maybe you need to be using the perl rename command. On my CentOS box, it's called 'prename'.



            $ ls
            IMG_1.JPG IMG_2.JPG IMG_3.JPG
            $ prename 's/^IMG/img/;s/.JPG$/.jpg/' *JPG
            $ ls
            img_1.jpg img_2.jpg img_3.jpg
            $

            $ prename -h
            Usage: prename [OPTION]... PERLEXPR FILE...
            Rename FILE(s) using PERLEXPR on each filename.

            -b, --backup make backup before removal
            -B, --prefix=SUFFIX set backup filename prefix
            -f, --force remove existing destinations, never prompt
            -i, --interactive prompt before overwrite
            -l, --link-only link file instead of reame
            -n, --just-print, --dry-run don't rename, implies --verbose
            -v, --verbose explain what is being done
            -V, --version-control=METHOD override the usual version control
            -Y, --basename-prefix=PREFIX set backup filename basename prefix
            -z, -S, --suffix=SUFFIX set backup filename suffix
            --help display this help and exit
            --version output version information and exit

            The backup suffix is ~, unless set with SIMPLE_BACKUP_SUFFIX. The
            version control may be set with VERSION_CONTROL, values are:

            numbered, t make numbered backups
            existing, nil numbered if numbered backups exist, simple otherwise
            simple, never always make simple backups

            Report bugs to pederst@cpan.org
            $


            If you want to use the dumb rename command from util-linux (sometimes called rename.ul), perhaps needs doing in two steps, e.g.



            $ ls
            IMG_1.JPG IMG_2.JPG IMG_3.JPG
            $ rename IMG img *JPG
            $ rename JPG jpg *JPG
            $ ls
            img_1.jpg img_2.jpg img_3.jpg
            $





            share|improve this answer



















            • 3




              Note that the perl rename predates the dumb rename found in util-linux that you call plain old rename. It even predates Linux.
              – Stéphane Chazelas
              Jul 27 at 14:49











            • Thanks, didnt realise that, revised
              – steve
              Jul 27 at 14:52












            up vote
            10
            down vote



            accepted







            up vote
            10
            down vote



            accepted






            Maybe you need to be using the perl rename command. On my CentOS box, it's called 'prename'.



            $ ls
            IMG_1.JPG IMG_2.JPG IMG_3.JPG
            $ prename 's/^IMG/img/;s/.JPG$/.jpg/' *JPG
            $ ls
            img_1.jpg img_2.jpg img_3.jpg
            $

            $ prename -h
            Usage: prename [OPTION]... PERLEXPR FILE...
            Rename FILE(s) using PERLEXPR on each filename.

            -b, --backup make backup before removal
            -B, --prefix=SUFFIX set backup filename prefix
            -f, --force remove existing destinations, never prompt
            -i, --interactive prompt before overwrite
            -l, --link-only link file instead of reame
            -n, --just-print, --dry-run don't rename, implies --verbose
            -v, --verbose explain what is being done
            -V, --version-control=METHOD override the usual version control
            -Y, --basename-prefix=PREFIX set backup filename basename prefix
            -z, -S, --suffix=SUFFIX set backup filename suffix
            --help display this help and exit
            --version output version information and exit

            The backup suffix is ~, unless set with SIMPLE_BACKUP_SUFFIX. The
            version control may be set with VERSION_CONTROL, values are:

            numbered, t make numbered backups
            existing, nil numbered if numbered backups exist, simple otherwise
            simple, never always make simple backups

            Report bugs to pederst@cpan.org
            $


            If you want to use the dumb rename command from util-linux (sometimes called rename.ul), perhaps needs doing in two steps, e.g.



            $ ls
            IMG_1.JPG IMG_2.JPG IMG_3.JPG
            $ rename IMG img *JPG
            $ rename JPG jpg *JPG
            $ ls
            img_1.jpg img_2.jpg img_3.jpg
            $





            share|improve this answer















            Maybe you need to be using the perl rename command. On my CentOS box, it's called 'prename'.



            $ ls
            IMG_1.JPG IMG_2.JPG IMG_3.JPG
            $ prename 's/^IMG/img/;s/.JPG$/.jpg/' *JPG
            $ ls
            img_1.jpg img_2.jpg img_3.jpg
            $

            $ prename -h
            Usage: prename [OPTION]... PERLEXPR FILE...
            Rename FILE(s) using PERLEXPR on each filename.

            -b, --backup make backup before removal
            -B, --prefix=SUFFIX set backup filename prefix
            -f, --force remove existing destinations, never prompt
            -i, --interactive prompt before overwrite
            -l, --link-only link file instead of reame
            -n, --just-print, --dry-run don't rename, implies --verbose
            -v, --verbose explain what is being done
            -V, --version-control=METHOD override the usual version control
            -Y, --basename-prefix=PREFIX set backup filename basename prefix
            -z, -S, --suffix=SUFFIX set backup filename suffix
            --help display this help and exit
            --version output version information and exit

            The backup suffix is ~, unless set with SIMPLE_BACKUP_SUFFIX. The
            version control may be set with VERSION_CONTROL, values are:

            numbered, t make numbered backups
            existing, nil numbered if numbered backups exist, simple otherwise
            simple, never always make simple backups

            Report bugs to pederst@cpan.org
            $


            If you want to use the dumb rename command from util-linux (sometimes called rename.ul), perhaps needs doing in two steps, e.g.



            $ ls
            IMG_1.JPG IMG_2.JPG IMG_3.JPG
            $ rename IMG img *JPG
            $ rename JPG jpg *JPG
            $ ls
            img_1.jpg img_2.jpg img_3.jpg
            $






            share|improve this answer















            share|improve this answer



            share|improve this answer








            edited Jul 27 at 14:56









            Stéphane Chazelas

            278k52512842




            278k52512842











            answered Jul 27 at 13:30









            steve

            11.9k22047




            11.9k22047







            • 3




              Note that the perl rename predates the dumb rename found in util-linux that you call plain old rename. It even predates Linux.
              – Stéphane Chazelas
              Jul 27 at 14:49











            • Thanks, didnt realise that, revised
              – steve
              Jul 27 at 14:52












            • 3




              Note that the perl rename predates the dumb rename found in util-linux that you call plain old rename. It even predates Linux.
              – Stéphane Chazelas
              Jul 27 at 14:49











            • Thanks, didnt realise that, revised
              – steve
              Jul 27 at 14:52







            3




            3




            Note that the perl rename predates the dumb rename found in util-linux that you call plain old rename. It even predates Linux.
            – Stéphane Chazelas
            Jul 27 at 14:49





            Note that the perl rename predates the dumb rename found in util-linux that you call plain old rename. It even predates Linux.
            – Stéphane Chazelas
            Jul 27 at 14:49













            Thanks, didnt realise that, revised
            – steve
            Jul 27 at 14:52




            Thanks, didnt realise that, revised
            – steve
            Jul 27 at 14:52












            up vote
            5
            down vote













            To answer you question in the generic,




            rename multiple files with 2 conditions/replacements in one line?




            you would typically use capture groups, referring to them in the replacement expression using their corresponding backreferences. For example



            $ rename -n 's/^(.*)_(.*).JPG$/L$1_$2.jpg/' *.JPG
            rename(IMG_2.JPG, img_2.jpg)
            rename(IMG_3.JPG, img_3.jpg)


            However, in this particular case, it would be simpler to just apply the lowercase modifier L to the whole name:



            $ rename -n 's/.*/L$&/' *.JPG
            rename(IMG_2.JPG, img_2.jpg)
            rename(IMG_3.JPG, img_3.jpg)


            Another alternative, using mmv



            $ mmv -n '*.JPG' '#l1.jpg'
            IMG_2.JPG -> img_2.jpg
            IMG_3.JPG -> img_3.jpg


            (remove the -n to actually perform the rename).






            share|improve this answer























            • Or zmv's: zmv '*.JPG' '$(L)f'
              – Stéphane Chazelas
              Jul 27 at 15:00






            • 1




              A simpler version of rename 's/.*/L$&/' *.JPG would be rename '$_ = lc' *.JPG
              – hobbs
              Jul 27 at 17:04














            up vote
            5
            down vote













            To answer you question in the generic,




            rename multiple files with 2 conditions/replacements in one line?




            you would typically use capture groups, referring to them in the replacement expression using their corresponding backreferences. For example



            $ rename -n 's/^(.*)_(.*).JPG$/L$1_$2.jpg/' *.JPG
            rename(IMG_2.JPG, img_2.jpg)
            rename(IMG_3.JPG, img_3.jpg)


            However, in this particular case, it would be simpler to just apply the lowercase modifier L to the whole name:



            $ rename -n 's/.*/L$&/' *.JPG
            rename(IMG_2.JPG, img_2.jpg)
            rename(IMG_3.JPG, img_3.jpg)


            Another alternative, using mmv



            $ mmv -n '*.JPG' '#l1.jpg'
            IMG_2.JPG -> img_2.jpg
            IMG_3.JPG -> img_3.jpg


            (remove the -n to actually perform the rename).






            share|improve this answer























            • Or zmv's: zmv '*.JPG' '$(L)f'
              – Stéphane Chazelas
              Jul 27 at 15:00






            • 1




              A simpler version of rename 's/.*/L$&/' *.JPG would be rename '$_ = lc' *.JPG
              – hobbs
              Jul 27 at 17:04












            up vote
            5
            down vote










            up vote
            5
            down vote









            To answer you question in the generic,




            rename multiple files with 2 conditions/replacements in one line?




            you would typically use capture groups, referring to them in the replacement expression using their corresponding backreferences. For example



            $ rename -n 's/^(.*)_(.*).JPG$/L$1_$2.jpg/' *.JPG
            rename(IMG_2.JPG, img_2.jpg)
            rename(IMG_3.JPG, img_3.jpg)


            However, in this particular case, it would be simpler to just apply the lowercase modifier L to the whole name:



            $ rename -n 's/.*/L$&/' *.JPG
            rename(IMG_2.JPG, img_2.jpg)
            rename(IMG_3.JPG, img_3.jpg)


            Another alternative, using mmv



            $ mmv -n '*.JPG' '#l1.jpg'
            IMG_2.JPG -> img_2.jpg
            IMG_3.JPG -> img_3.jpg


            (remove the -n to actually perform the rename).






            share|improve this answer















            To answer you question in the generic,




            rename multiple files with 2 conditions/replacements in one line?




            you would typically use capture groups, referring to them in the replacement expression using their corresponding backreferences. For example



            $ rename -n 's/^(.*)_(.*).JPG$/L$1_$2.jpg/' *.JPG
            rename(IMG_2.JPG, img_2.jpg)
            rename(IMG_3.JPG, img_3.jpg)


            However, in this particular case, it would be simpler to just apply the lowercase modifier L to the whole name:



            $ rename -n 's/.*/L$&/' *.JPG
            rename(IMG_2.JPG, img_2.jpg)
            rename(IMG_3.JPG, img_3.jpg)


            Another alternative, using mmv



            $ mmv -n '*.JPG' '#l1.jpg'
            IMG_2.JPG -> img_2.jpg
            IMG_3.JPG -> img_3.jpg


            (remove the -n to actually perform the rename).







            share|improve this answer















            share|improve this answer



            share|improve this answer








            edited Jul 27 at 14:18


























            answered Jul 27 at 14:02









            steeldriver

            30.8k34877




            30.8k34877











            • Or zmv's: zmv '*.JPG' '$(L)f'
              – Stéphane Chazelas
              Jul 27 at 15:00






            • 1




              A simpler version of rename 's/.*/L$&/' *.JPG would be rename '$_ = lc' *.JPG
              – hobbs
              Jul 27 at 17:04
















            • Or zmv's: zmv '*.JPG' '$(L)f'
              – Stéphane Chazelas
              Jul 27 at 15:00






            • 1




              A simpler version of rename 's/.*/L$&/' *.JPG would be rename '$_ = lc' *.JPG
              – hobbs
              Jul 27 at 17:04















            Or zmv's: zmv '*.JPG' '$(L)f'
            – Stéphane Chazelas
            Jul 27 at 15:00




            Or zmv's: zmv '*.JPG' '$(L)f'
            – Stéphane Chazelas
            Jul 27 at 15:00




            1




            1




            A simpler version of rename 's/.*/L$&/' *.JPG would be rename '$_ = lc' *.JPG
            – hobbs
            Jul 27 at 17:04




            A simpler version of rename 's/.*/L$&/' *.JPG would be rename '$_ = lc' *.JPG
            – hobbs
            Jul 27 at 17:04










            up vote
            2
            down vote













            Using mv:



            sh compatible:



            for file in *.JPG; do mv "$file" "$(echo "$file" | tr '[:upper:]' '[:lower:]')"; done


            bash (Thanks steeldriver):



            for file in *.JPG; do mv "$file" "$file,,"; done


            This will loop through all .JPG files in the current directory and rename them to the same name with all uppercase characters converted to lowercase characters.






            share|improve this answer



























              up vote
              2
              down vote













              Using mv:



              sh compatible:



              for file in *.JPG; do mv "$file" "$(echo "$file" | tr '[:upper:]' '[:lower:]')"; done


              bash (Thanks steeldriver):



              for file in *.JPG; do mv "$file" "$file,,"; done


              This will loop through all .JPG files in the current directory and rename them to the same name with all uppercase characters converted to lowercase characters.






              share|improve this answer

























                up vote
                2
                down vote










                up vote
                2
                down vote









                Using mv:



                sh compatible:



                for file in *.JPG; do mv "$file" "$(echo "$file" | tr '[:upper:]' '[:lower:]')"; done


                bash (Thanks steeldriver):



                for file in *.JPG; do mv "$file" "$file,,"; done


                This will loop through all .JPG files in the current directory and rename them to the same name with all uppercase characters converted to lowercase characters.






                share|improve this answer















                Using mv:



                sh compatible:



                for file in *.JPG; do mv "$file" "$(echo "$file" | tr '[:upper:]' '[:lower:]')"; done


                bash (Thanks steeldriver):



                for file in *.JPG; do mv "$file" "$file,,"; done


                This will loop through all .JPG files in the current directory and rename them to the same name with all uppercase characters converted to lowercase characters.







                share|improve this answer















                share|improve this answer



                share|improve this answer








                edited Jul 27 at 13:41


























                answered Jul 27 at 13:32









                Jesse_b

                10.1k12658




                10.1k12658




















                    up vote
                    1
                    down vote













                    The simplest way and based on the man page that does not cover a regular expression:



                    rename 'IMG' 'img' * ; rename 'JPG' 'jpg' *





                    share|improve this answer























                    • IMHO, a simple answer like this achieves what the heavy hitting occasionally fails to. No malice towards seasoned programmers, but since the question seems to be from a newbie, simplicity needs to be encouraged.
                      – Hopping Bunny
                      Aug 1 at 6:04














                    up vote
                    1
                    down vote













                    The simplest way and based on the man page that does not cover a regular expression:



                    rename 'IMG' 'img' * ; rename 'JPG' 'jpg' *





                    share|improve this answer























                    • IMHO, a simple answer like this achieves what the heavy hitting occasionally fails to. No malice towards seasoned programmers, but since the question seems to be from a newbie, simplicity needs to be encouraged.
                      – Hopping Bunny
                      Aug 1 at 6:04












                    up vote
                    1
                    down vote










                    up vote
                    1
                    down vote









                    The simplest way and based on the man page that does not cover a regular expression:



                    rename 'IMG' 'img' * ; rename 'JPG' 'jpg' *





                    share|improve this answer















                    The simplest way and based on the man page that does not cover a regular expression:



                    rename 'IMG' 'img' * ; rename 'JPG' 'jpg' *






                    share|improve this answer















                    share|improve this answer



                    share|improve this answer








                    edited Jul 27 at 21:56









                    Peter Mortensen

                    76548




                    76548











                    answered Jul 27 at 17:54









                    Hossein Vatani

                    45927




                    45927











                    • IMHO, a simple answer like this achieves what the heavy hitting occasionally fails to. No malice towards seasoned programmers, but since the question seems to be from a newbie, simplicity needs to be encouraged.
                      – Hopping Bunny
                      Aug 1 at 6:04
















                    • IMHO, a simple answer like this achieves what the heavy hitting occasionally fails to. No malice towards seasoned programmers, but since the question seems to be from a newbie, simplicity needs to be encouraged.
                      – Hopping Bunny
                      Aug 1 at 6:04















                    IMHO, a simple answer like this achieves what the heavy hitting occasionally fails to. No malice towards seasoned programmers, but since the question seems to be from a newbie, simplicity needs to be encouraged.
                    – Hopping Bunny
                    Aug 1 at 6:04




                    IMHO, a simple answer like this achieves what the heavy hitting occasionally fails to. No malice towards seasoned programmers, but since the question seems to be from a newbie, simplicity needs to be encouraged.
                    – Hopping Bunny
                    Aug 1 at 6:04












                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f458839%2frename-multiple-files-with-2-conditions-replacements-in-one-line%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay