adding text to filename before extension

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












21















I would like to add text to the end of filename but before the extension. Right now I am trying,



for f in *.shp; do echo $f_poly; done



the output is,



Quercus_acutifolia.shp_poly
Quercus_agrifolia.shp_poly
Quercus_corrugata.shp_poly
Quercus_cortesii.shp_poly
Quercus_costaricensis.shp_poly
Quercus_havardii.shp_poly
Quercus_hemisphaerica.shp_poly
Quercus_kelloggii.shp_poly
Quercus_knoblochii.shp_poly
Quercus_laceyi.shp_poly


I want it to be,



Quercus_acutifolia_poly.shp
Quercus_agrifolia_poly.shp
Quercus_corrugata_poly.shp
Quercus_cortesii_poly.shp
Quercus_costaricensis_poly.shp
Quercus_havardii_poly.shp
Quercus_hemisphaerica_poly.shp
Quercus_kelloggii_poly.shp
Quercus_knoblochii_poly.shp
Quercus_laceyi_poly.shp









share|improve this question




























    21















    I would like to add text to the end of filename but before the extension. Right now I am trying,



    for f in *.shp; do echo $f_poly; done



    the output is,



    Quercus_acutifolia.shp_poly
    Quercus_agrifolia.shp_poly
    Quercus_corrugata.shp_poly
    Quercus_cortesii.shp_poly
    Quercus_costaricensis.shp_poly
    Quercus_havardii.shp_poly
    Quercus_hemisphaerica.shp_poly
    Quercus_kelloggii.shp_poly
    Quercus_knoblochii.shp_poly
    Quercus_laceyi.shp_poly


    I want it to be,



    Quercus_acutifolia_poly.shp
    Quercus_agrifolia_poly.shp
    Quercus_corrugata_poly.shp
    Quercus_cortesii_poly.shp
    Quercus_costaricensis_poly.shp
    Quercus_havardii_poly.shp
    Quercus_hemisphaerica_poly.shp
    Quercus_kelloggii_poly.shp
    Quercus_knoblochii_poly.shp
    Quercus_laceyi_poly.shp









    share|improve this question


























      21












      21








      21


      10






      I would like to add text to the end of filename but before the extension. Right now I am trying,



      for f in *.shp; do echo $f_poly; done



      the output is,



      Quercus_acutifolia.shp_poly
      Quercus_agrifolia.shp_poly
      Quercus_corrugata.shp_poly
      Quercus_cortesii.shp_poly
      Quercus_costaricensis.shp_poly
      Quercus_havardii.shp_poly
      Quercus_hemisphaerica.shp_poly
      Quercus_kelloggii.shp_poly
      Quercus_knoblochii.shp_poly
      Quercus_laceyi.shp_poly


      I want it to be,



      Quercus_acutifolia_poly.shp
      Quercus_agrifolia_poly.shp
      Quercus_corrugata_poly.shp
      Quercus_cortesii_poly.shp
      Quercus_costaricensis_poly.shp
      Quercus_havardii_poly.shp
      Quercus_hemisphaerica_poly.shp
      Quercus_kelloggii_poly.shp
      Quercus_knoblochii_poly.shp
      Quercus_laceyi_poly.shp









      share|improve this question
















      I would like to add text to the end of filename but before the extension. Right now I am trying,



      for f in *.shp; do echo $f_poly; done



      the output is,



      Quercus_acutifolia.shp_poly
      Quercus_agrifolia.shp_poly
      Quercus_corrugata.shp_poly
      Quercus_cortesii.shp_poly
      Quercus_costaricensis.shp_poly
      Quercus_havardii.shp_poly
      Quercus_hemisphaerica.shp_poly
      Quercus_kelloggii.shp_poly
      Quercus_knoblochii.shp_poly
      Quercus_laceyi.shp_poly


      I want it to be,



      Quercus_acutifolia_poly.shp
      Quercus_agrifolia_poly.shp
      Quercus_corrugata_poly.shp
      Quercus_cortesii_poly.shp
      Quercus_costaricensis_poly.shp
      Quercus_havardii_poly.shp
      Quercus_hemisphaerica_poly.shp
      Quercus_kelloggii_poly.shp
      Quercus_knoblochii_poly.shp
      Quercus_laceyi_poly.shp






      bash rename filenames






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 26 '12 at 23:55









      Gilles

      540k12810941609




      540k12810941609










      asked Nov 26 '12 at 20:59









      Sam007Sam007

      208127




      208127




















          6 Answers
          6






          active

          oldest

          votes


















          23














          Using standard POSIX parameter expansion:



          for f in *.shp; do printf '%sn' "$f%.shp_poly.shp"; done





          share|improve this answer























          • Awesome that is exactly what I needed.

            – Sam007
            Nov 26 '12 at 21:05











          • Might be better with an explanation how it works. The Doug answer is pretty easy, on the other hand.

            – Sarge Borsch
            Jun 23 '15 at 12:41











          • @SargeBorsch What do you need explained? My answer, the snippet in the question, and Doug's answer are only differ by a few characters, and Doug's answer explains even less than mine so I don't know what it is you want. If you just compare the difference in the two outputs in the question it should be trivially easy to figure out what they do. I can explain why my answer is preferable to Doug's. 1. I use printf with a format string instead of the less portable echo. 2. I use parameter expansion which is more efficient than calling an external binary (basename) for such a simple task.

            – jw013
            Jun 23 '15 at 14:43











          • Then the command to rename the files would be this: for f in *.shp; do mv $f $f%.shp_poly.shp; done

            – Patch92
            Feb 13 at 12:28


















          6














          Sometimes there is a tool called "rename" installed.



          rename 's/.shp$/_poly.shp/' *shp


          It might not be portable but it is easy to use.






          share|improve this answer


















          • 1





            This is the only one that worked for me, great answer!

            – wanderer0810
            Dec 22 '17 at 6:57


















          4














          Use this:



          for file in *.shp; do echo $(basename $file .shp)_poly.shp; done





          share|improve this answer




















          • 3





            Using basename is slower and less efficient than letting the shell do the work by itself. This may be noticeable for very large numbers of files.

            – jw013
            Nov 26 '12 at 21:14











          • Also, there are missing quotes and --s and it fails for filenames that have newline characters before the .shp.

            – Stéphane Chazelas
            Nov 16 '16 at 22:57



















          2














          This worked better for me:



          for f in *; do NEW=$f%.webm_2016.webm; mv $f "$NEW"; done






          share|improve this answer























          • Well this looks a lot like the accepted answer except that you probably want for f in *.webm, you forgot to quote the $f and you're missing a --.

            – Stéphane Chazelas
            Nov 16 '16 at 22:45






          • 1





            The accepted answer doesnt work on OSX, it only prints out the new file names, it doesnt actually rename the files

            – Vinnie James
            Nov 16 '16 at 22:47







          • 1





            Of course, it shows you how to use shell expansions to get the new file name, in response to the question that is also outputing a file name (with echo), but not the required one.

            – Stéphane Chazelas
            Nov 16 '16 at 22:54



















          0














          If they are in different locations then run :-



          for i in ` find /root/test/ -name "*.shp" ` ;
          do
          mv $i ` echo $i | sed 's/.shp$/_poly.shp/g' ` ;
          done





          share|improve this answer
































            0














            As the question is for bash there is no need for external utilities, since you can use bash regexps:



            for i in *.shp
            do
            mv -v "$i" "$i%.*_MYSUFFIX.$i##*."
            done





            share|improve this answer






















              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',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              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%2f56810%2fadding-text-to-filename-before-extension%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              6 Answers
              6






              active

              oldest

              votes








              6 Answers
              6






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              23














              Using standard POSIX parameter expansion:



              for f in *.shp; do printf '%sn' "$f%.shp_poly.shp"; done





              share|improve this answer























              • Awesome that is exactly what I needed.

                – Sam007
                Nov 26 '12 at 21:05











              • Might be better with an explanation how it works. The Doug answer is pretty easy, on the other hand.

                – Sarge Borsch
                Jun 23 '15 at 12:41











              • @SargeBorsch What do you need explained? My answer, the snippet in the question, and Doug's answer are only differ by a few characters, and Doug's answer explains even less than mine so I don't know what it is you want. If you just compare the difference in the two outputs in the question it should be trivially easy to figure out what they do. I can explain why my answer is preferable to Doug's. 1. I use printf with a format string instead of the less portable echo. 2. I use parameter expansion which is more efficient than calling an external binary (basename) for such a simple task.

                – jw013
                Jun 23 '15 at 14:43











              • Then the command to rename the files would be this: for f in *.shp; do mv $f $f%.shp_poly.shp; done

                – Patch92
                Feb 13 at 12:28















              23














              Using standard POSIX parameter expansion:



              for f in *.shp; do printf '%sn' "$f%.shp_poly.shp"; done





              share|improve this answer























              • Awesome that is exactly what I needed.

                – Sam007
                Nov 26 '12 at 21:05











              • Might be better with an explanation how it works. The Doug answer is pretty easy, on the other hand.

                – Sarge Borsch
                Jun 23 '15 at 12:41











              • @SargeBorsch What do you need explained? My answer, the snippet in the question, and Doug's answer are only differ by a few characters, and Doug's answer explains even less than mine so I don't know what it is you want. If you just compare the difference in the two outputs in the question it should be trivially easy to figure out what they do. I can explain why my answer is preferable to Doug's. 1. I use printf with a format string instead of the less portable echo. 2. I use parameter expansion which is more efficient than calling an external binary (basename) for such a simple task.

                – jw013
                Jun 23 '15 at 14:43











              • Then the command to rename the files would be this: for f in *.shp; do mv $f $f%.shp_poly.shp; done

                – Patch92
                Feb 13 at 12:28













              23












              23








              23







              Using standard POSIX parameter expansion:



              for f in *.shp; do printf '%sn' "$f%.shp_poly.shp"; done





              share|improve this answer













              Using standard POSIX parameter expansion:



              for f in *.shp; do printf '%sn' "$f%.shp_poly.shp"; done






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Nov 26 '12 at 21:02









              jw013jw013

              36.6k7101125




              36.6k7101125












              • Awesome that is exactly what I needed.

                – Sam007
                Nov 26 '12 at 21:05











              • Might be better with an explanation how it works. The Doug answer is pretty easy, on the other hand.

                – Sarge Borsch
                Jun 23 '15 at 12:41











              • @SargeBorsch What do you need explained? My answer, the snippet in the question, and Doug's answer are only differ by a few characters, and Doug's answer explains even less than mine so I don't know what it is you want. If you just compare the difference in the two outputs in the question it should be trivially easy to figure out what they do. I can explain why my answer is preferable to Doug's. 1. I use printf with a format string instead of the less portable echo. 2. I use parameter expansion which is more efficient than calling an external binary (basename) for such a simple task.

                – jw013
                Jun 23 '15 at 14:43











              • Then the command to rename the files would be this: for f in *.shp; do mv $f $f%.shp_poly.shp; done

                – Patch92
                Feb 13 at 12:28

















              • Awesome that is exactly what I needed.

                – Sam007
                Nov 26 '12 at 21:05











              • Might be better with an explanation how it works. The Doug answer is pretty easy, on the other hand.

                – Sarge Borsch
                Jun 23 '15 at 12:41











              • @SargeBorsch What do you need explained? My answer, the snippet in the question, and Doug's answer are only differ by a few characters, and Doug's answer explains even less than mine so I don't know what it is you want. If you just compare the difference in the two outputs in the question it should be trivially easy to figure out what they do. I can explain why my answer is preferable to Doug's. 1. I use printf with a format string instead of the less portable echo. 2. I use parameter expansion which is more efficient than calling an external binary (basename) for such a simple task.

                – jw013
                Jun 23 '15 at 14:43











              • Then the command to rename the files would be this: for f in *.shp; do mv $f $f%.shp_poly.shp; done

                – Patch92
                Feb 13 at 12:28
















              Awesome that is exactly what I needed.

              – Sam007
              Nov 26 '12 at 21:05





              Awesome that is exactly what I needed.

              – Sam007
              Nov 26 '12 at 21:05













              Might be better with an explanation how it works. The Doug answer is pretty easy, on the other hand.

              – Sarge Borsch
              Jun 23 '15 at 12:41





              Might be better with an explanation how it works. The Doug answer is pretty easy, on the other hand.

              – Sarge Borsch
              Jun 23 '15 at 12:41













              @SargeBorsch What do you need explained? My answer, the snippet in the question, and Doug's answer are only differ by a few characters, and Doug's answer explains even less than mine so I don't know what it is you want. If you just compare the difference in the two outputs in the question it should be trivially easy to figure out what they do. I can explain why my answer is preferable to Doug's. 1. I use printf with a format string instead of the less portable echo. 2. I use parameter expansion which is more efficient than calling an external binary (basename) for such a simple task.

              – jw013
              Jun 23 '15 at 14:43





              @SargeBorsch What do you need explained? My answer, the snippet in the question, and Doug's answer are only differ by a few characters, and Doug's answer explains even less than mine so I don't know what it is you want. If you just compare the difference in the two outputs in the question it should be trivially easy to figure out what they do. I can explain why my answer is preferable to Doug's. 1. I use printf with a format string instead of the less portable echo. 2. I use parameter expansion which is more efficient than calling an external binary (basename) for such a simple task.

              – jw013
              Jun 23 '15 at 14:43













              Then the command to rename the files would be this: for f in *.shp; do mv $f $f%.shp_poly.shp; done

              – Patch92
              Feb 13 at 12:28





              Then the command to rename the files would be this: for f in *.shp; do mv $f $f%.shp_poly.shp; done

              – Patch92
              Feb 13 at 12:28













              6














              Sometimes there is a tool called "rename" installed.



              rename 's/.shp$/_poly.shp/' *shp


              It might not be portable but it is easy to use.






              share|improve this answer


















              • 1





                This is the only one that worked for me, great answer!

                – wanderer0810
                Dec 22 '17 at 6:57















              6














              Sometimes there is a tool called "rename" installed.



              rename 's/.shp$/_poly.shp/' *shp


              It might not be portable but it is easy to use.






              share|improve this answer


















              • 1





                This is the only one that worked for me, great answer!

                – wanderer0810
                Dec 22 '17 at 6:57













              6












              6








              6







              Sometimes there is a tool called "rename" installed.



              rename 's/.shp$/_poly.shp/' *shp


              It might not be portable but it is easy to use.






              share|improve this answer













              Sometimes there is a tool called "rename" installed.



              rename 's/.shp$/_poly.shp/' *shp


              It might not be portable but it is easy to use.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Nov 27 '12 at 21:09









              Chad ClarkChad Clark

              26614




              26614







              • 1





                This is the only one that worked for me, great answer!

                – wanderer0810
                Dec 22 '17 at 6:57












              • 1





                This is the only one that worked for me, great answer!

                – wanderer0810
                Dec 22 '17 at 6:57







              1




              1





              This is the only one that worked for me, great answer!

              – wanderer0810
              Dec 22 '17 at 6:57





              This is the only one that worked for me, great answer!

              – wanderer0810
              Dec 22 '17 at 6:57











              4














              Use this:



              for file in *.shp; do echo $(basename $file .shp)_poly.shp; done





              share|improve this answer




















              • 3





                Using basename is slower and less efficient than letting the shell do the work by itself. This may be noticeable for very large numbers of files.

                – jw013
                Nov 26 '12 at 21:14











              • Also, there are missing quotes and --s and it fails for filenames that have newline characters before the .shp.

                – Stéphane Chazelas
                Nov 16 '16 at 22:57
















              4














              Use this:



              for file in *.shp; do echo $(basename $file .shp)_poly.shp; done





              share|improve this answer




















              • 3





                Using basename is slower and less efficient than letting the shell do the work by itself. This may be noticeable for very large numbers of files.

                – jw013
                Nov 26 '12 at 21:14











              • Also, there are missing quotes and --s and it fails for filenames that have newline characters before the .shp.

                – Stéphane Chazelas
                Nov 16 '16 at 22:57














              4












              4








              4







              Use this:



              for file in *.shp; do echo $(basename $file .shp)_poly.shp; done





              share|improve this answer















              Use this:



              for file in *.shp; do echo $(basename $file .shp)_poly.shp; done






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Nov 26 '12 at 22:14









              Michael Durrant

              16.2k44121184




              16.2k44121184










              answered Nov 26 '12 at 21:05









              Doug O'NealDoug O'Neal

              2,9501818




              2,9501818







              • 3





                Using basename is slower and less efficient than letting the shell do the work by itself. This may be noticeable for very large numbers of files.

                – jw013
                Nov 26 '12 at 21:14











              • Also, there are missing quotes and --s and it fails for filenames that have newline characters before the .shp.

                – Stéphane Chazelas
                Nov 16 '16 at 22:57













              • 3





                Using basename is slower and less efficient than letting the shell do the work by itself. This may be noticeable for very large numbers of files.

                – jw013
                Nov 26 '12 at 21:14











              • Also, there are missing quotes and --s and it fails for filenames that have newline characters before the .shp.

                – Stéphane Chazelas
                Nov 16 '16 at 22:57








              3




              3





              Using basename is slower and less efficient than letting the shell do the work by itself. This may be noticeable for very large numbers of files.

              – jw013
              Nov 26 '12 at 21:14





              Using basename is slower and less efficient than letting the shell do the work by itself. This may be noticeable for very large numbers of files.

              – jw013
              Nov 26 '12 at 21:14













              Also, there are missing quotes and --s and it fails for filenames that have newline characters before the .shp.

              – Stéphane Chazelas
              Nov 16 '16 at 22:57






              Also, there are missing quotes and --s and it fails for filenames that have newline characters before the .shp.

              – Stéphane Chazelas
              Nov 16 '16 at 22:57












              2














              This worked better for me:



              for f in *; do NEW=$f%.webm_2016.webm; mv $f "$NEW"; done






              share|improve this answer























              • Well this looks a lot like the accepted answer except that you probably want for f in *.webm, you forgot to quote the $f and you're missing a --.

                – Stéphane Chazelas
                Nov 16 '16 at 22:45






              • 1





                The accepted answer doesnt work on OSX, it only prints out the new file names, it doesnt actually rename the files

                – Vinnie James
                Nov 16 '16 at 22:47







              • 1





                Of course, it shows you how to use shell expansions to get the new file name, in response to the question that is also outputing a file name (with echo), but not the required one.

                – Stéphane Chazelas
                Nov 16 '16 at 22:54
















              2














              This worked better for me:



              for f in *; do NEW=$f%.webm_2016.webm; mv $f "$NEW"; done






              share|improve this answer























              • Well this looks a lot like the accepted answer except that you probably want for f in *.webm, you forgot to quote the $f and you're missing a --.

                – Stéphane Chazelas
                Nov 16 '16 at 22:45






              • 1





                The accepted answer doesnt work on OSX, it only prints out the new file names, it doesnt actually rename the files

                – Vinnie James
                Nov 16 '16 at 22:47







              • 1





                Of course, it shows you how to use shell expansions to get the new file name, in response to the question that is also outputing a file name (with echo), but not the required one.

                – Stéphane Chazelas
                Nov 16 '16 at 22:54














              2












              2








              2







              This worked better for me:



              for f in *; do NEW=$f%.webm_2016.webm; mv $f "$NEW"; done






              share|improve this answer













              This worked better for me:



              for f in *; do NEW=$f%.webm_2016.webm; mv $f "$NEW"; done







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Nov 16 '16 at 22:35









              Vinnie JamesVinnie James

              1213




              1213












              • Well this looks a lot like the accepted answer except that you probably want for f in *.webm, you forgot to quote the $f and you're missing a --.

                – Stéphane Chazelas
                Nov 16 '16 at 22:45






              • 1





                The accepted answer doesnt work on OSX, it only prints out the new file names, it doesnt actually rename the files

                – Vinnie James
                Nov 16 '16 at 22:47







              • 1





                Of course, it shows you how to use shell expansions to get the new file name, in response to the question that is also outputing a file name (with echo), but not the required one.

                – Stéphane Chazelas
                Nov 16 '16 at 22:54


















              • Well this looks a lot like the accepted answer except that you probably want for f in *.webm, you forgot to quote the $f and you're missing a --.

                – Stéphane Chazelas
                Nov 16 '16 at 22:45






              • 1





                The accepted answer doesnt work on OSX, it only prints out the new file names, it doesnt actually rename the files

                – Vinnie James
                Nov 16 '16 at 22:47







              • 1





                Of course, it shows you how to use shell expansions to get the new file name, in response to the question that is also outputing a file name (with echo), but not the required one.

                – Stéphane Chazelas
                Nov 16 '16 at 22:54

















              Well this looks a lot like the accepted answer except that you probably want for f in *.webm, you forgot to quote the $f and you're missing a --.

              – Stéphane Chazelas
              Nov 16 '16 at 22:45





              Well this looks a lot like the accepted answer except that you probably want for f in *.webm, you forgot to quote the $f and you're missing a --.

              – Stéphane Chazelas
              Nov 16 '16 at 22:45




              1




              1





              The accepted answer doesnt work on OSX, it only prints out the new file names, it doesnt actually rename the files

              – Vinnie James
              Nov 16 '16 at 22:47






              The accepted answer doesnt work on OSX, it only prints out the new file names, it doesnt actually rename the files

              – Vinnie James
              Nov 16 '16 at 22:47





              1




              1





              Of course, it shows you how to use shell expansions to get the new file name, in response to the question that is also outputing a file name (with echo), but not the required one.

              – Stéphane Chazelas
              Nov 16 '16 at 22:54






              Of course, it shows you how to use shell expansions to get the new file name, in response to the question that is also outputing a file name (with echo), but not the required one.

              – Stéphane Chazelas
              Nov 16 '16 at 22:54












              0














              If they are in different locations then run :-



              for i in ` find /root/test/ -name "*.shp" ` ;
              do
              mv $i ` echo $i | sed 's/.shp$/_poly.shp/g' ` ;
              done





              share|improve this answer





























                0














                If they are in different locations then run :-



                for i in ` find /root/test/ -name "*.shp" ` ;
                do
                mv $i ` echo $i | sed 's/.shp$/_poly.shp/g' ` ;
                done





                share|improve this answer



























                  0












                  0








                  0







                  If they are in different locations then run :-



                  for i in ` find /root/test/ -name "*.shp" ` ;
                  do
                  mv $i ` echo $i | sed 's/.shp$/_poly.shp/g' ` ;
                  done





                  share|improve this answer















                  If they are in different locations then run :-



                  for i in ` find /root/test/ -name "*.shp" ` ;
                  do
                  mv $i ` echo $i | sed 's/.shp$/_poly.shp/g' ` ;
                  done






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Oct 6 '15 at 10:29









                  X Tian

                  7,72712136




                  7,72712136










                  answered Oct 6 '15 at 10:23









                  Shankey RaviShankey Ravi

                  1




                  1





















                      0














                      As the question is for bash there is no need for external utilities, since you can use bash regexps:



                      for i in *.shp
                      do
                      mv -v "$i" "$i%.*_MYSUFFIX.$i##*."
                      done





                      share|improve this answer



























                        0














                        As the question is for bash there is no need for external utilities, since you can use bash regexps:



                        for i in *.shp
                        do
                        mv -v "$i" "$i%.*_MYSUFFIX.$i##*."
                        done





                        share|improve this answer

























                          0












                          0








                          0







                          As the question is for bash there is no need for external utilities, since you can use bash regexps:



                          for i in *.shp
                          do
                          mv -v "$i" "$i%.*_MYSUFFIX.$i##*."
                          done





                          share|improve this answer













                          As the question is for bash there is no need for external utilities, since you can use bash regexps:



                          for i in *.shp
                          do
                          mv -v "$i" "$i%.*_MYSUFFIX.$i##*."
                          done






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Feb 11 at 14:53









                          ccpizzaccpizza

                          62179




                          62179



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Unix & Linux Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f56810%2fadding-text-to-filename-before-extension%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown






                              Popular posts from this blog

                              Peggy Mitchell

                              Palaiologos

                              The Forum (Inglewood, California)