8 Replies Latest reply: Nov 16, 2008 6:46 AM by red_menace
Jirka Cech Level 1 Level 1 (0 points)
Hi,
I have just imported 165 mp3 files, which do have nice and proper ID3 tags but song name is in wrong format, it is like: "123.Songname" or, three digit and dot, no space, then the real name. Is there some automatic way how to remove first four characters from the name of each song?

MacBook, Mac OS X (10.4.11)
  • red_menace Level 6 Level 6 (14,845 points)
    I have a script that I wrote to strip the first word (track number) of a file name that should do the trick. It can be run as a script, applet, or droplet. Spaces, periods, and dashes (not underscores) are word delimiters, so filenames that begin with any number separated by one of those are renamed:

    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px; height: 340px;
    color: #000000;
    background-color: #FFDDFF;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    -- strip CD track numbers
    -- contents of subfolders are not read

    property SingleFile : false -- set to true to select individual files

    on run -- double-clicked
    if SingleFile then
    set FileList to (choose file with multiple selections allowed without invisibles)
    else
    set FileList to (choose folder with multiple selections allowed without invisibles)
    end if
    open FileList
    end run

    on open FileList -- items dropped
    set MyList to {}
    repeat with SomeFile in FileList
    if folder of (info for SomeFile) then -- expand folder contents
    try
    tell application "Finder" to set MyList to MyList & (get every file of SomeFile) as alias list
    on error -- Tiger
    tell application "Finder" to set MyList to MyList & (get every file of SomeFile) as alias as list
    end try
    else
    set the end of MyList to SomeFile
    end if
    end repeat

    tell application "Finder" to repeat with SomeFile in MyList
    set TheName to the name of SomeFile
    try -- strip a track number prefix if it exists
    get (the first word of TheName) as number as text -- "words" are delimiter sensitive
    set the name of SomeFile to text (word 2) thru -1 of TheName
    end try
    end repeat
    end open
    </pre>
  • Limnos Level 8 Level 8 (43,035 points)
    renamer4mac is a freeware utility that lets you rename files with lots and lots of features such as trimming off the first four characters, etc.
  • Jirka Cech Level 1 Level 1 (0 points)
    well, But i have to change it in iTunes, ie in ID3 tag, change of filename itself would be rather useless. Just imagine, you can have file blabla.mp3 but the songname and artist info are anything but blabla, since they are stored in ID3 tag and/or iTunes DB.
  • Limnos Level 8 Level 8 (43,035 points)
    Ah, I was confused by, "which do have nice and proper ID3 tags" and assumed they were all fine.

    Option: See if a program such as Media rage lets you do what you want. It has all kinds of tag editing features but some of them take a bit of learning.

    Option: Do rename your files using renamer and re-import them.

    Or maybe the script the other poster provided does what you want.
  • red_menace Level 6 Level 6 (14,845 points)
    I don't know how your playlists are set up, so I am guessing that you still have (or can replace) the "Recently Added" smart playlist. You will probably need to edit the parameters to get the number of your new additions, but try this:

    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #FFDDFF;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    tell application "iTunes"
    set MyList to (get tracks of playlist "Recently Added")

    repeat with SomeTrack in MyList
    set TheName to the name of SomeTrack
    try -- strip a track number prefix if it exists
    get (the first word of TheName) as number -- "words" are delimiter sensitive
    set the name of SomeTrack to text (word 2) thru -1 of TheName
    end try
    end repeat
    end tell
    </pre>
  • BDAqua Level 10 Level 10 (120,375 points)
    Hi Jirka, and a warm welcome to the forums!

    Here's the closet thing I can find...

    http://www.versiontracker.com/dyn/moreinfo/macosx/28200

    PS. Looks like Red Menace stopped in with a better easier solution!

    Message was edited by: BDAqua
  • Jirka Cech Level 1 Level 1 (0 points)
    that seem like a solution, I will test it soon, but how is it delimited? you have XYZ.Name, where XYZ are numbers and then goes dot and then (without space or so) name of song.
  • red_menace Level 6 Level 6 (14,845 points)
    When you get "words" of something, the text is broken up along non-word boundaries, which includes whitespace and various punctuation marks such as a period or dash. Getting the words of "123.whatever name" results in word 1 being "123" and word 2 being "whatever" (completely skipping the period). Then it is just a matter of testing the first word to see if it is a number, and getting the rest of the text from the second word on if it is.