Unix gurus, how do you batch rename multiple folders

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Just Alex
    Liv Benson to You, Bitch
    • Aug 2007
    • 6060

    #1

    Unix gurus, how do you batch rename multiple folders

    Lets say I have them 001, 002, 003 .. etc.. How can I rename them 200,201,202 or just do 1-001, 1-002, 1-003

    Anyone knows a command or script?
  • MaDalton
    I am Amazing Content!
    • Feb 2004
    • 39864

    #2
    i use total commander via ftp
    AmazingContent.com - providing only the best content and service since 2003
    Monetize your content on Veegaz.com - one of Germanies largest VOD sites
    Got German traffic? We convert it into money for you!
    Email: oltecconsult [at] gmail [dot] com

    Comment

    • gleem
      Confirmed User
      • Jun 2001
      • 5593

      #3
      I used this to rename extensions, should work on folders too:

      http://lab.artlung.com/unix-batch-file-rename/

      just replace the "00" part with "200"




      Contact me: \\// E: webmaster /at/ unprofessional.com

      Comment

      • raymor
        Confirmed User
        • Oct 2002
        • 3745

        #4
        Check out "man rename". An example

        rename 'foo' 'bar' dir*

        dir_foo1/ becomes dir_bar1/
        dir_foo2/ becomes dir_bar2/

        Originally posted by Just Alex
        Lets say I have them 001, 002, 003 .. etc.. How can I rename them ... 1-001, 1-002, 1-003
        For that specifically:
        rename "" "1-" 0*
        Last edited by raymor; 01-31-2012, 10:00 AM.
        For historical display only. This information is not current:
        support@bettercgi.com ICQ 7208627
        Strongbox - The next generation in site security
        Throttlebox - The next generation in bandwidth control
        Clonebox - Backup and disaster recovery on steroids

        Comment

        • Just Alex
          Liv Benson to You, Bitch
          • Aug 2007
          • 6060

          #5
          Thanks guys

          Comment

          • fris
            I have to go potty
            • Aug 2002
            • 55928

            #6
            if you wanted to renaming inside the folders for say imagesr like akjs.jpg bigpacks.jpg etc and rename them to 1.jpg 2.jpg 3.jpg.

            Code:
            #!/bin/bash
            
            i=1; 
            shopt -s nullglob; 
            
            for f in *.{jpg,jpeg,JPG,JPEG,gif,GIF,png,PNG}; do     
            	ext="${f##*.}"; 
            	ext=${ext,,}; 
            	ext=${ext/jpeg/jpg};     
            	mv -- "$f" "newfolder/$i.${ext}";     
            	((i++)); 
            done
            Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


            Only Fans Data

            20+ Custom Adult Themes and Plugins

            Comment

            Working...