How to rename multiple files in Bash Scripting? [closed]

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











up vote
0
down vote

favorite












Suppose i want to rename 3 files in the same directory.
Example:
test1.gzip
test2.gzip
test3.gzip



Now want to rename all the above files to something like,



test1_20180518.gzip
test2_20180518.gzip
test3_20180518.gzip



Now how can get the result? Someone please help!!



Please tell me, how to do that in bash scripting?







share|improve this question













closed as unclear what you're asking by Jeff Schaller, Kusalananda, Isaac, G-Man, GAD3R May 29 at 8:58


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 4




    What happened when you tried? What are the zip file names? You know you can only rename one file at a time?
    – Jeff Schaller
    May 28 at 16:22






  • 2




    In the title you say “gunzip” but in the body you say “zip” — what are they?
    – Jeff Schaller
    May 28 at 16:23






  • 1




    Also, gunzip is a verb; it expands the contents of a gzip file. Are you trying to do that, or rename, or what?
    – Jeff Schaller
    May 28 at 16:23






  • 2




    You might also want to read How do I ask a good question?
    – glenn jackman
    May 28 at 16:40






  • 3




    Search this site for "rename multiple files" and you'll find lots of similar questions.
    – glenn jackman
    May 28 at 16:46















up vote
0
down vote

favorite












Suppose i want to rename 3 files in the same directory.
Example:
test1.gzip
test2.gzip
test3.gzip



Now want to rename all the above files to something like,



test1_20180518.gzip
test2_20180518.gzip
test3_20180518.gzip



Now how can get the result? Someone please help!!



Please tell me, how to do that in bash scripting?







share|improve this question













closed as unclear what you're asking by Jeff Schaller, Kusalananda, Isaac, G-Man, GAD3R May 29 at 8:58


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 4




    What happened when you tried? What are the zip file names? You know you can only rename one file at a time?
    – Jeff Schaller
    May 28 at 16:22






  • 2




    In the title you say “gunzip” but in the body you say “zip” — what are they?
    – Jeff Schaller
    May 28 at 16:23






  • 1




    Also, gunzip is a verb; it expands the contents of a gzip file. Are you trying to do that, or rename, or what?
    – Jeff Schaller
    May 28 at 16:23






  • 2




    You might also want to read How do I ask a good question?
    – glenn jackman
    May 28 at 16:40






  • 3




    Search this site for "rename multiple files" and you'll find lots of similar questions.
    – glenn jackman
    May 28 at 16:46













up vote
0
down vote

favorite









up vote
0
down vote

favorite











Suppose i want to rename 3 files in the same directory.
Example:
test1.gzip
test2.gzip
test3.gzip



Now want to rename all the above files to something like,



test1_20180518.gzip
test2_20180518.gzip
test3_20180518.gzip



Now how can get the result? Someone please help!!



Please tell me, how to do that in bash scripting?







share|improve this question













Suppose i want to rename 3 files in the same directory.
Example:
test1.gzip
test2.gzip
test3.gzip



Now want to rename all the above files to something like,



test1_20180518.gzip
test2_20180518.gzip
test3_20180518.gzip



Now how can get the result? Someone please help!!



Please tell me, how to do that in bash scripting?









share|improve this question












share|improve this question




share|improve this question








edited May 28 at 18:05
























asked May 28 at 16:15









Red Phoenix

13




13




closed as unclear what you're asking by Jeff Schaller, Kusalananda, Isaac, G-Man, GAD3R May 29 at 8:58


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as unclear what you're asking by Jeff Schaller, Kusalananda, Isaac, G-Man, GAD3R May 29 at 8:58


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 4




    What happened when you tried? What are the zip file names? You know you can only rename one file at a time?
    – Jeff Schaller
    May 28 at 16:22






  • 2




    In the title you say “gunzip” but in the body you say “zip” — what are they?
    – Jeff Schaller
    May 28 at 16:23






  • 1




    Also, gunzip is a verb; it expands the contents of a gzip file. Are you trying to do that, or rename, or what?
    – Jeff Schaller
    May 28 at 16:23






  • 2




    You might also want to read How do I ask a good question?
    – glenn jackman
    May 28 at 16:40






  • 3




    Search this site for "rename multiple files" and you'll find lots of similar questions.
    – glenn jackman
    May 28 at 16:46













  • 4




    What happened when you tried? What are the zip file names? You know you can only rename one file at a time?
    – Jeff Schaller
    May 28 at 16:22






  • 2




    In the title you say “gunzip” but in the body you say “zip” — what are they?
    – Jeff Schaller
    May 28 at 16:23






  • 1




    Also, gunzip is a verb; it expands the contents of a gzip file. Are you trying to do that, or rename, or what?
    – Jeff Schaller
    May 28 at 16:23






  • 2




    You might also want to read How do I ask a good question?
    – glenn jackman
    May 28 at 16:40






  • 3




    Search this site for "rename multiple files" and you'll find lots of similar questions.
    – glenn jackman
    May 28 at 16:46








4




4




What happened when you tried? What are the zip file names? You know you can only rename one file at a time?
– Jeff Schaller
May 28 at 16:22




What happened when you tried? What are the zip file names? You know you can only rename one file at a time?
– Jeff Schaller
May 28 at 16:22




2




2




In the title you say “gunzip” but in the body you say “zip” — what are they?
– Jeff Schaller
May 28 at 16:23




In the title you say “gunzip” but in the body you say “zip” — what are they?
– Jeff Schaller
May 28 at 16:23




1




1




Also, gunzip is a verb; it expands the contents of a gzip file. Are you trying to do that, or rename, or what?
– Jeff Schaller
May 28 at 16:23




Also, gunzip is a verb; it expands the contents of a gzip file. Are you trying to do that, or rename, or what?
– Jeff Schaller
May 28 at 16:23




2




2




You might also want to read How do I ask a good question?
– glenn jackman
May 28 at 16:40




You might also want to read How do I ask a good question?
– glenn jackman
May 28 at 16:40




3




3




Search this site for "rename multiple files" and you'll find lots of similar questions.
– glenn jackman
May 28 at 16:46





Search this site for "rename multiple files" and you'll find lots of similar questions.
– glenn jackman
May 28 at 16:46











2 Answers
2






active

oldest

votes

















up vote
1
down vote













Check your "rename" version with rename -V. If you see:




  • "util-linux" then



    rename .gzip _$(date "+%Y%m%d").gzip *.gzip



  • "File::Rename" then



    rename 'chomp(my $date = `date "+%Y%m%d"`); s/.gzip/_$date.gzip/' *.gzip






share|improve this answer




























    up vote
    0
    down vote













    Posible solution (you need chose one in loop body):



    #!/bin/bash

    pattern="pattern"
    i=0

    for file in `find <your_path> -type f -name '*.zip'`
    do
    extension="$file##*."
    filename="$file%.*"

    # without extenstion
    mv "$file" "$filename-$pattern.$extension"

    # whole filename
    mv "$file" "$pattern-$i"
    i=$((i + 1))
    done





    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













      Check your "rename" version with rename -V. If you see:




      • "util-linux" then



        rename .gzip _$(date "+%Y%m%d").gzip *.gzip



      • "File::Rename" then



        rename 'chomp(my $date = `date "+%Y%m%d"`); s/.gzip/_$date.gzip/' *.gzip






      share|improve this answer

























        up vote
        1
        down vote













        Check your "rename" version with rename -V. If you see:




        • "util-linux" then



          rename .gzip _$(date "+%Y%m%d").gzip *.gzip



        • "File::Rename" then



          rename 'chomp(my $date = `date "+%Y%m%d"`); s/.gzip/_$date.gzip/' *.gzip






        share|improve this answer























          up vote
          1
          down vote










          up vote
          1
          down vote









          Check your "rename" version with rename -V. If you see:




          • "util-linux" then



            rename .gzip _$(date "+%Y%m%d").gzip *.gzip



          • "File::Rename" then



            rename 'chomp(my $date = `date "+%Y%m%d"`); s/.gzip/_$date.gzip/' *.gzip






          share|improve this answer













          Check your "rename" version with rename -V. If you see:




          • "util-linux" then



            rename .gzip _$(date "+%Y%m%d").gzip *.gzip



          • "File::Rename" then



            rename 'chomp(my $date = `date "+%Y%m%d"`); s/.gzip/_$date.gzip/' *.gzip







          share|improve this answer













          share|improve this answer



          share|improve this answer











          answered May 28 at 16:54









          glenn jackman

          45.7k265100




          45.7k265100






















              up vote
              0
              down vote













              Posible solution (you need chose one in loop body):



              #!/bin/bash

              pattern="pattern"
              i=0

              for file in `find <your_path> -type f -name '*.zip'`
              do
              extension="$file##*."
              filename="$file%.*"

              # without extenstion
              mv "$file" "$filename-$pattern.$extension"

              # whole filename
              mv "$file" "$pattern-$i"
              i=$((i + 1))
              done





              share|improve this answer

























                up vote
                0
                down vote













                Posible solution (you need chose one in loop body):



                #!/bin/bash

                pattern="pattern"
                i=0

                for file in `find <your_path> -type f -name '*.zip'`
                do
                extension="$file##*."
                filename="$file%.*"

                # without extenstion
                mv "$file" "$filename-$pattern.$extension"

                # whole filename
                mv "$file" "$pattern-$i"
                i=$((i + 1))
                done





                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Posible solution (you need chose one in loop body):



                  #!/bin/bash

                  pattern="pattern"
                  i=0

                  for file in `find <your_path> -type f -name '*.zip'`
                  do
                  extension="$file##*."
                  filename="$file%.*"

                  # without extenstion
                  mv "$file" "$filename-$pattern.$extension"

                  # whole filename
                  mv "$file" "$pattern-$i"
                  i=$((i + 1))
                  done





                  share|improve this answer













                  Posible solution (you need chose one in loop body):



                  #!/bin/bash

                  pattern="pattern"
                  i=0

                  for file in `find <your_path> -type f -name '*.zip'`
                  do
                  extension="$file##*."
                  filename="$file%.*"

                  # without extenstion
                  mv "$file" "$filename-$pattern.$extension"

                  # whole filename
                  mv "$file" "$pattern-$i"
                  i=$((i + 1))
                  done






                  share|improve this answer













                  share|improve this answer



                  share|improve this answer











                  answered May 28 at 16:56









                  Yurij Goncharuk

                  2,2582521




                  2,2582521












                      Popular posts from this blog

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

                      Displaying single band from multi-band raster using QGIS

                      How many registers does an x86_64 CPU actually have?