Announcement

Collapse
No announcement yet.

Program to rename files

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Program to rename files

    I don't know much about programming but i need a program that renames all the files on a linux directory like this: whatever.mp3 to 001.mp3 or anything to 002.ogg. So i can send them to my dos mp3car without any problems. I know samba does that mangling thing but i need to rename the files on linux in order to make a playlist on my linux computer that is playable on the dos system.

    Thanks in advance!

  • #2
    try this
    http://www.icewalkers.com/Linux/Soft...20460/mvb.html
    (i googled it)
    William Surritte, Technician
    No Limit Technologies
    1931 U.S. HWY. 160, Caulfield, MO 65626
    http://home.centurytel.net/nolimititech/
    Planning: |++++ |
    Software Development: |++++ |
    Hardware Development: |++ |

    Comment


    • #3
      I have been looking into something similar but don't have to worry about the 8.3 restriction and will be using ID3 tagging for music. Check out this project, it can rename and retag mp3s based upon the music signature. http://musicbrainz.org
      -pkg

      Check out my tC: http://publicjestering.com/tc
      Check out my site: http://publicjestering.com

      Comment


      • #4
        Here's a bash shell script that will do the trick. It's quick and dirty. It doesn't do any error checking, if your files are named songsdasdasd.foobar, it won't truncate the extension to 3 characters. It will make sure not to write a filename bigger than 8 digits though.

        I take no responsibility for this script. If it sets your puppy on fire and makes your child cry, that's your business.
        Code:
        ----- Beginning of script, don't include this line ------
        #!/bin/bash
        i=1;
        for file in *
        do
           ext=${file##*.}
           if [ "$file" != "$i.$ext" ]; then
              echo "moving $file to $i.$ext"
              mv $file $i.$ext
           else
              echo "skipping $file, already renamed."
           fi
           let i+=1
           if [ "$i" -gt "99999999" ]; then
              echo "too many files to fit in 8.3 naming scheme"
              break;
           fi
        done
        ----- End of script, don't include this line ------
        My worklog.
        Status: VM GTI sold, got out of the CarPC tinkering hobby, but I still think about getting back in.

        Comment


        • #5
          Interesting you're taking that approach. That's how my custom software imports files into it's permanent library, although I have no concern with DOS (when it imports it renames files as xxxxxx.mp3 and keeps track of where it left off for the next import).

          You can use the find command like this to create a readable text file you can then iterate through to rename your files:

          Code:
          find /source/of/mp3/files -name '*.mp3' -follow > /temp/text/file
          You can then use a simple for loop to iterate it as such:

          Code:
          COUNTER=0
          for MP3FILE in `cat /temp/text/file` ;
          do
              mv MP3FILE /destination/path/$COUNTER.mp3
              COUNTER=$((COUNTER++))
          done
          rm /temp/text/file
          I didn't test this but you get the idea. Hope that helps.
          Silverwolf 2 is dead.
          Silverwolf 3...?

          Comment


          • #6
            Originally posted by intuitionsys
            Interesting you're taking that approach. That's how my custom software imports files into it's permanent library,
            Huh, did I come up with almost the exact code? I didn't plan it out or anything, I'm sure there are better ways to solve the problem. I just started typing, tested it once and posted the code.
            My worklog.
            Status: VM GTI sold, got out of the CarPC tinkering hobby, but I still think about getting back in.

            Comment


            • #7
              You did more than me I mainly posted the snippet re "find" as it will find files recursively if that's of any use.
              Silverwolf 2 is dead.
              Silverwolf 3...?

              Comment

              Working...
              X