Results 1 to 7 of 7

Thread: Command Line Question

  1. #1
    Join Date
    May 2007
    Location
    Earth,MiWaGa,LoGr,ViSuCl
    Beans
    310
    Distro
    Ubuntu 10.04 Lucid Lynx

    Command Line Question

    lets say I have a folder 10 files

    file1
    file2
    ...

    how could I from the command-line rename all 10 files prepending them with an underscore "_" (so they move to the top of the folder alphabetically.

    Thanks!

  2. #2
    Join Date
    Jun 2011
    Location
    The Shadow Gallery
    Beans
    6,815

    Re: Command Line Question

    Quote Originally Posted by johntkucz View Post
    lets say I have a folder 10 files

    file1
    file2
    ...

    how could I from the command-line rename all 10 files prepending them with an underscore "_" (so they move to the top of the folder alphabetically.

    Thanks!
    Code:
    man rename
    I could type the syntax but prefer to give people the fishing rod to catch their own fish
    Feel Free to Bitcoin Tip: 135Rp4pwwYTHEJ4u8bxKaDQiC91N9LUoV2

    Backtrack - Giving machine guns to monkeys since 2006
    Kali-Linux - Adding a grenade launcher to the machine guns since 2013

  3. #3
    Join Date
    Jul 2011
    Beans
    Hidden!
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: Command Line Question

    I second haqking's opinion.

    Just note that, while using rename command, you might have to work a bit with perl expressions.

  4. #4
    Dangertux is offline Chocolate Ubuntu Mocha Blend
    Join Date
    Jun 2011
    Location
    Atlanta Georgia
    Beans
    1,771
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Command Line Question

    or just use a bash for loop

    Code:
    for i in file* ; do mv "$i" "${file/i}" _file; done

  5. #5
    Join Date
    Jun 2011
    Location
    The Shadow Gallery
    Beans
    6,815

    Re: Command Line Question

    Quote Originally Posted by Dangertux View Post
    or just use a bash for loop

    Code:
    for i in file* ; do mv "$i" "${i/file*}" _file; done
    poser
    Feel Free to Bitcoin Tip: 135Rp4pwwYTHEJ4u8bxKaDQiC91N9LUoV2

    Backtrack - Giving machine guns to monkeys since 2006
    Kali-Linux - Adding a grenade launcher to the machine guns since 2013

  6. #6
    Dangertux is offline Chocolate Ubuntu Mocha Blend
    Join Date
    Jun 2011
    Location
    Atlanta Georgia
    Beans
    1,771
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Command Line Question

    haters gonna hate

  7. #7
    Join Date
    Jun 2011
    Location
    The Shadow Gallery
    Beans
    6,815

    Re: Command Line Question

    Quote Originally Posted by Dangertux View Post
    haters gonna hate
    before anyone reports abuse....me and dangertux the poser are quite happy and are not arguing....LOL
    Feel Free to Bitcoin Tip: 135Rp4pwwYTHEJ4u8bxKaDQiC91N9LUoV2

    Backtrack - Giving machine guns to monkeys since 2006
    Kali-Linux - Adding a grenade launcher to the machine guns since 2013

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •