Results 1 to 7 of 7

Thread: Renaming a large amount of files while retaining the order?

  1. #1
    Join Date
    Mar 2013
    Beans
    32

    Renaming a large amount of files while retaining the order?

    Hi all, I've got a possibly nooby question, I'm not sure. This is my firt forum post btw ^_^ .I've downloaded about 100 videos off of youtube, but alot of them are named something different even though they're from the same playlist. What I want to do is just rename the file to Mpt(order number here).mp4. I know what I want to do, but am not sure about the syntax.

    So what I have in mind is something like this...

    mv Mass(number in series here, ideally I would like it to read the number as a variable).mp4 Mpt(the var number here).mp4

    Can anyone help me??

  2. #2
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,332
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Renaming a large amount of files while retaining the order?

    more details about naming convention would be nice, some examples?
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  3. #3
    Join Date
    Mar 2013
    Beans
    32

    Re: Renaming a large amount of files while retaining the order?

    The majority of the files I dl'd are named "Mass Effect 3 PC Sentinel INSANITY pt.(insert number here).mp4. I want to name as Mpt(insert number here).mp4

  4. #4
    Join Date
    Mar 2013
    Beans
    32

    Re: Renaming a large amount of files while retaining the order?

    Is there no help for a computer-illiterate's son?

  5. #5
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,332
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Renaming a large amount of files while retaining the order?

    Code:
    for f in "Mass Effect 3"*[0-9].mp4; do n=${f%.*}; n=${n##*[^0-9]}; echo mv "$f" "Mpt${n}.mp4"; done
    Code:
    rename -nv 's/.*[^0-9]([0-9]+[.]mp4$)/Mpt$1/' "Mass Effect 3"*[0-9].mp4
    both of these won't actually rename files but print out what would happen if echo/n (bolded) were not present.
    Last edited by Vaphell; March 27th, 2013 at 03:33 AM.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  6. #6
    Join Date
    Mar 2013
    Beans
    32

    Re: Renaming a large amount of files while retaining the order?

    Thank you very much

  7. #7
    Join Date
    Mar 2013
    Beans
    32

    Re: Renaming a large amount of files while retaining the order?

    How do I close /:

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
  •