Rename a specific part of a lot of files [duplicate]











up vote
2
down vote

favorite













This question already has an answer here:




  • Batch renaming files

    14 answers




I have a bunch of files named:



Brooklyn Nine-Nine S01 E01 [H264].mkv
Brooklyn Nine-Nine S01 E02 [H264].mkv
Brooklyn Nine-Nine S01 E03 [H264].mkv
Brooklyn Nine-Nine S01 E04 [H264].mkv
Brooklyn Nine-Nine S01 E05 [H264].mkv
Brooklyn Nine-Nine S01 E06 [H264].mkv
Brooklyn Nine-Nine S01 E07 [H264].mkv
Brooklyn Nine-Nine S01 E08 [H264].mkv
...


I want to rename them so that the space Between S01 and E08 is removed.
example



Brooklyn Nine-Nine S01E08 [H264].mkv


I already found a command to remove all spaces:



IFS="n"
for file in *.mkv;
do
mv "$file" "${file/[[:space:]]}"
done


but I only want to remove space between Sxx and Exx.










share|improve this question









New contributor




Stiefel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











marked as duplicate by Jenny D, schily, G-Man, Isaac, GAD3R yesterday


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















    up vote
    2
    down vote

    favorite













    This question already has an answer here:




    • Batch renaming files

      14 answers




    I have a bunch of files named:



    Brooklyn Nine-Nine S01 E01 [H264].mkv
    Brooklyn Nine-Nine S01 E02 [H264].mkv
    Brooklyn Nine-Nine S01 E03 [H264].mkv
    Brooklyn Nine-Nine S01 E04 [H264].mkv
    Brooklyn Nine-Nine S01 E05 [H264].mkv
    Brooklyn Nine-Nine S01 E06 [H264].mkv
    Brooklyn Nine-Nine S01 E07 [H264].mkv
    Brooklyn Nine-Nine S01 E08 [H264].mkv
    ...


    I want to rename them so that the space Between S01 and E08 is removed.
    example



    Brooklyn Nine-Nine S01E08 [H264].mkv


    I already found a command to remove all spaces:



    IFS="n"
    for file in *.mkv;
    do
    mv "$file" "${file/[[:space:]]}"
    done


    but I only want to remove space between Sxx and Exx.










    share|improve this question









    New contributor




    Stiefel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.











    marked as duplicate by Jenny D, schily, G-Man, Isaac, GAD3R yesterday


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

















      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite












      This question already has an answer here:




      • Batch renaming files

        14 answers




      I have a bunch of files named:



      Brooklyn Nine-Nine S01 E01 [H264].mkv
      Brooklyn Nine-Nine S01 E02 [H264].mkv
      Brooklyn Nine-Nine S01 E03 [H264].mkv
      Brooklyn Nine-Nine S01 E04 [H264].mkv
      Brooklyn Nine-Nine S01 E05 [H264].mkv
      Brooklyn Nine-Nine S01 E06 [H264].mkv
      Brooklyn Nine-Nine S01 E07 [H264].mkv
      Brooklyn Nine-Nine S01 E08 [H264].mkv
      ...


      I want to rename them so that the space Between S01 and E08 is removed.
      example



      Brooklyn Nine-Nine S01E08 [H264].mkv


      I already found a command to remove all spaces:



      IFS="n"
      for file in *.mkv;
      do
      mv "$file" "${file/[[:space:]]}"
      done


      but I only want to remove space between Sxx and Exx.










      share|improve this question









      New contributor




      Stiefel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      This question already has an answer here:




      • Batch renaming files

        14 answers




      I have a bunch of files named:



      Brooklyn Nine-Nine S01 E01 [H264].mkv
      Brooklyn Nine-Nine S01 E02 [H264].mkv
      Brooklyn Nine-Nine S01 E03 [H264].mkv
      Brooklyn Nine-Nine S01 E04 [H264].mkv
      Brooklyn Nine-Nine S01 E05 [H264].mkv
      Brooklyn Nine-Nine S01 E06 [H264].mkv
      Brooklyn Nine-Nine S01 E07 [H264].mkv
      Brooklyn Nine-Nine S01 E08 [H264].mkv
      ...


      I want to rename them so that the space Between S01 and E08 is removed.
      example



      Brooklyn Nine-Nine S01E08 [H264].mkv


      I already found a command to remove all spaces:



      IFS="n"
      for file in *.mkv;
      do
      mv "$file" "${file/[[:space:]]}"
      done


      but I only want to remove space between Sxx and Exx.





      This question already has an answer here:




      • Batch renaming files

        14 answers








      rename






      share|improve this question









      New contributor




      Stiefel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      Stiefel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 2 days ago









      msp9011

      3,64043863




      3,64043863






      New contributor




      Stiefel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 days ago









      Stiefel

      161




      161




      New contributor




      Stiefel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Stiefel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Stiefel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      marked as duplicate by Jenny D, schily, G-Man, Isaac, GAD3R yesterday


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by Jenny D, schily, G-Man, Isaac, GAD3R yesterday


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote













          The easiest way is to use the rename tool, which lets you do a simple search-and-replace in many filenames:



          rename [options] <expression> <replacement> <file>...



          Something like this should do:



          rename " E0" E0 Brooklyn*.mkv



          Note that if you're using a Debian-like distribution, your rename command probably calls a Perl script with a different input syntax instead of the usual utility from util-linux. In that case, use rename.ul to call the right tool. Why is the rename utility on Debian/Ubuntu different than the one on other distributions, like CentOS?






          share|improve this answer






























            up vote
            0
            down vote













            The for loop can be edited as follows:



            for file in *.mkv;
            do
            mv "$file" "${file//S01 E0/S01E0}"
            done


            or using the rename command:



            rename 's/S01 E0/S01E0/' *.mkv





            share|improve this answer




























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              1
              down vote













              The easiest way is to use the rename tool, which lets you do a simple search-and-replace in many filenames:



              rename [options] <expression> <replacement> <file>...



              Something like this should do:



              rename " E0" E0 Brooklyn*.mkv



              Note that if you're using a Debian-like distribution, your rename command probably calls a Perl script with a different input syntax instead of the usual utility from util-linux. In that case, use rename.ul to call the right tool. Why is the rename utility on Debian/Ubuntu different than the one on other distributions, like CentOS?






              share|improve this answer



























                up vote
                1
                down vote













                The easiest way is to use the rename tool, which lets you do a simple search-and-replace in many filenames:



                rename [options] <expression> <replacement> <file>...



                Something like this should do:



                rename " E0" E0 Brooklyn*.mkv



                Note that if you're using a Debian-like distribution, your rename command probably calls a Perl script with a different input syntax instead of the usual utility from util-linux. In that case, use rename.ul to call the right tool. Why is the rename utility on Debian/Ubuntu different than the one on other distributions, like CentOS?






                share|improve this answer

























                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  The easiest way is to use the rename tool, which lets you do a simple search-and-replace in many filenames:



                  rename [options] <expression> <replacement> <file>...



                  Something like this should do:



                  rename " E0" E0 Brooklyn*.mkv



                  Note that if you're using a Debian-like distribution, your rename command probably calls a Perl script with a different input syntax instead of the usual utility from util-linux. In that case, use rename.ul to call the right tool. Why is the rename utility on Debian/Ubuntu different than the one on other distributions, like CentOS?






                  share|improve this answer














                  The easiest way is to use the rename tool, which lets you do a simple search-and-replace in many filenames:



                  rename [options] <expression> <replacement> <file>...



                  Something like this should do:



                  rename " E0" E0 Brooklyn*.mkv



                  Note that if you're using a Debian-like distribution, your rename command probably calls a Perl script with a different input syntax instead of the usual utility from util-linux. In that case, use rename.ul to call the right tool. Why is the rename utility on Debian/Ubuntu different than the one on other distributions, like CentOS?







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 2 days ago

























                  answered 2 days ago









                  TooTea

                  535110




                  535110
























                      up vote
                      0
                      down vote













                      The for loop can be edited as follows:



                      for file in *.mkv;
                      do
                      mv "$file" "${file//S01 E0/S01E0}"
                      done


                      or using the rename command:



                      rename 's/S01 E0/S01E0/' *.mkv





                      share|improve this answer

























                        up vote
                        0
                        down vote













                        The for loop can be edited as follows:



                        for file in *.mkv;
                        do
                        mv "$file" "${file//S01 E0/S01E0}"
                        done


                        or using the rename command:



                        rename 's/S01 E0/S01E0/' *.mkv





                        share|improve this answer























                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote









                          The for loop can be edited as follows:



                          for file in *.mkv;
                          do
                          mv "$file" "${file//S01 E0/S01E0}"
                          done


                          or using the rename command:



                          rename 's/S01 E0/S01E0/' *.mkv





                          share|improve this answer












                          The for loop can be edited as follows:



                          for file in *.mkv;
                          do
                          mv "$file" "${file//S01 E0/S01E0}"
                          done


                          or using the rename command:



                          rename 's/S01 E0/S01E0/' *.mkv






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 2 days ago









                          GAD3R

                          24.8k1749104




                          24.8k1749104















                              Popular posts from this blog

                              サソリ

                              広島県道265号伴広島線

                              Accessing regular linux commands in Huawei's Dopra Linux