The Notebook Review forums were hosted by TechTarget, who shut down them down on January 31, 2022. This static read-only archive was pulled by NBR forum users between January 20 and January 31, 2022, in an effort to make sure that the valuable technical information that had been posted on the forums is preserved. For current discussions, many NBR forum users moved over to NotebookTalk.net after the shutdown.
Problems? See this thread at archive.org.

    Batch change file extension

    Discussion in 'Apple and Mac OS X' started by masterchef341, May 27, 2008.

  1. masterchef341

    masterchef341 The guy from The Notebook

    Reputations:
    3,047
    Messages:
    8,636
    Likes Received:
    4
    Trophy Points:
    206
    Anyone know how to do this? I am trying to rename a bunch of *.m4a files to *.m4b

    any help is appreciated.
     
  2. sulkorp

    sulkorp Notebook Deity

    Reputations:
    145
    Messages:
    1,192
    Likes Received:
    0
    Trophy Points:
    55
  3. system_159

    system_159 Notebook Deity

    Reputations:
    363
    Messages:
    794
    Likes Received:
    0
    Trophy Points:
    30
    Try this applescript.

    Code:
    <START APPLESCRIPT>
    
    set thePath to choose folder with prompt "Select folder to rename files in:"
    set ext to display dialog "Extension to Replace:" default answer ""
    set ext to text returned of ext
    set extNew to display dialog "Replace With:" default answer ""
    set extNew to text returned of extNew
    
    tell application "Finder"
        try
            set the datlist to ¬
                ((every file in thePath whose name ends with ext) as alias) ¬
                    as list -- set name criteria
        on error number -1700 from f
            set datlist to f as list
        end try
        repeat with dat in datlist --list of alias references to the files
            select file dat
            set workingName to the name of dat as text
            set theOffset to offset of ext in workingName
            set chopped to characters 1 through (theOffset - 1) of workingName
            set newName to chopped & extNew as text
            set name of selection to newName
        end repeat
    end tell
    
    
    <END APPLESCRIPT>