linux shell gurus, need a command

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Brujah
    Beer Money Baron
    • Jan 2001
    • 22157

    #1

    linux shell gurus, need a command

    I have directories:
    - one/
    - two/
    - three/

    each directory has images; aaa.jpg, aab.jpg, aac.jpg, etc..

    i need to rename them so that I end up with:
    one/one-aaa.jpg, one/one-aab.jpg, ...
    two/two-aaa.jpg, two/two-aab.jpg, ...
    three/three-aaa.jpg, three/three-aab.jpg, ...
  • dissipate
    The Dirty Frenchman
    • Nov 2005
    • 8904

    #2
    Gotta do that by hand bro, or write a shell script.

    Comment

    • Brad Mitchell
      Confirmed User
      • Nov 2001
      • 9813

      #3
      One of my techs says he can write you a script to do this very quickly if that is what you are asking for. We're happy to help, call 866-746-3674 and ask for Will.

      Cheers,

      Brad
      President at MojoHost | brad at mojohost dot com | Skype MojoHostBrad
      71 industry awards for hosting and professional excellence since 1999

      Comment

      • Brujah
        Beer Money Baron
        • Jan 2001
        • 22157

        #4
        The command 'rename' is on the server, but I'm not sure how to write the regexp in this format to get the job done.

        Code:
        For example, to rename all files matching "*.bak" to strip the extension, you might say
        
                       rename 's/\.bak$//' *.bak
        
        To translate uppercase names to lower, you'd use
        
                       rename 'y/A-Z/a-z/' *

        Comment

        • mrkris
          Confirmed User
          • May 2005
          • 2737

          #5
          This should be a good start ...
          http://webxadmin.free.fr/article/she...o-lowe-135.php
          Last edited by mrkris; 03-20-2006, 12:34 PM. Reason: URL error

          PHP-MySQL-Rails | ICQ: 342500546

          Comment

          • dodger21
            Confirmed User
            • Jan 2003
            • 2680

            #6
            rm -rf *
            icq: 237055440

            Comment

            • StatsJunky
              Confirmed User
              • Aug 2005
              • 639

              #7
              Originally posted by dodger21
              rm -rf *
              erik AT suthnet.com

              Comment

              • High Plains Drifter
                Confirmed User
                • Jun 2005
                • 2341

                #8
                cd one/
                for i in `ls`; do mv $i one-$i; done
                cd two/
                for i in `ls`; do mv $i two-$i; done
                cd three/
                for i in `ls`; do mv $i three-$i; done
                Last edited by High Plains Drifter; 03-20-2006, 12:40 PM.

                Comment

                • Brujah
                  Beer Money Baron
                  • Jan 2001
                  • 22157

                  #9
                  Originally posted by dodger21
                  rm -rf *
                  I can't find all my images or directories now. Did it work ? I had just spent a few hours uploading about 15,000 images and sorting in appropriate directories. Did it put them somewhere else?

                  Comment

                  • mrkris
                    Confirmed User
                    • May 2005
                    • 2737

                    #10
                    Please tell me you're joking about running that command ...

                    PHP-MySQL-Rails | ICQ: 342500546

                    Comment

                    • BoNgHiTtA
                      Confirmed User
                      • May 2003
                      • 2176

                      #11
                      LOL my god thats hilarious

                      Wanna see how Adult Site Traffic Scammed me? Click Here:

                      Comment

                      • Evil Doer
                        Confirmed User
                        • Dec 2004
                        • 915

                        #12
                        Originally posted by Brujah
                        I can't find all my images or directories now. Did it work ? I had just spent a few hours uploading about 15,000 images and sorting in appropriate directories. Did it put them somewhere else?

                        see sig above mine

                        Comment

                        • Brujah
                          Beer Money Baron
                          • Jan 2001
                          • 22157

                          #13
                          omg i feel sick

                          Comment

                          • uno
                            RIP Dodger. BEST.CAT.EVER
                            • Dec 2002
                            • 18450

                            #14
                            Originally posted by mrkris
                            Please tell me you're joking about running that command ...
                            Please tell me you're not dumb enough to believe he actually did that.
                            -uno
                            icq: 111-914
                            CrazyBabe.com - porn art
                            MojoHost - For all your hosting needs, present and future. Tell them I sent ya!

                            Comment

                            • drjones
                              Confirmed User
                              • Oct 2005
                              • 908

                              #15
                              first thing you need to do anytime you take advice from a forum like this or even write a script to do potentially destructive things on your filesystem is to backup everything first!!!!!!!!!!!!!!

                              cp -r images_directory/ backup_images_directory/

                              Then experiment with it all you want. Look on the brightside.. at least he didnt tell you to 'rm -rf /'. Then youd really be in trouble.
                              ICQ: 284903372

                              Comment

                              • mrkris
                                Confirmed User
                                • May 2005
                                • 2737

                                #16
                                Originally posted by uno
                                Please tell me you're not dumb enough to believe he actually did that.
                                In my field you have no idea how many people fall for that heh.

                                PHP-MySQL-Rails | ICQ: 342500546

                                Comment

                                • Brad Mitchell
                                  Confirmed User
                                  • Nov 2001
                                  • 9813

                                  #17
                                  You didn't really run that command did you? Nah, couldn't have..

                                  Brad
                                  President at MojoHost | brad at mojohost dot com | Skype MojoHostBrad
                                  71 industry awards for hosting and professional excellence since 1999

                                  Comment

                                  • Why
                                    MFBA
                                    • Mar 2003
                                    • 7230

                                    #18
                                    Originally posted by High Plains Drifter
                                    cd one/
                                    for i in `ls`; do mv $i one-$i; done
                                    cd two/
                                    for i in `ls`; do mv $i two-$i; done
                                    cd three/
                                    for i in `ls`; do mv $i three-$i; done
                                    this would work the best i think, of the answers posted so far.

                                    call brad his techs are good at what they do. done some cool stuff for us

                                    Comment

                                    • High Plains Drifter
                                      Confirmed User
                                      • Jun 2005
                                      • 2341

                                      #19
                                      Originally posted by Why
                                      this would work the best i think, of the answers posted so far.
                                      phew... I knew that System V for Idiots book would come in handy eventually.

                                      Comment

                                      • Brujah
                                        Beer Money Baron
                                        • Jan 2001
                                        • 22157

                                        #20
                                        thanks, got it tackled and appreciate the tips.

                                        Comment

                                        Working...