Monday, December 11, 2017

#1 2002-02-19 09:43:20 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

batch: add file extension

Okay, I've got an app that requires the mp3s to have a .mp3 extension for it to read them. However a large number of the mp3 files in my music directory do not have the .mp3 extension. Some do and some do not, they're all mixed together.
How can I get the finder to open a folder and do the following: If it's a folder, leave it alone, if the file already has a .mp3 extension, leave it alone and if the file does not have a .mp3 extension, append one to the end of the filename.
I'm really not all that good at applescript and it would be a waste of time for me to add .mp3 manually to every file.
BTW I'm in mac os x running 10.1.3


One mans trash is another mans treasure

Offline

 

#2 2002-02-19 11:41:09 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: batch: add file extension

Okay, I modified Greg Strange's Recursion handler and came up with this, keep in mind that it is untested.. you need to save it as an applet and drop your folder/folders on it.

Applescript:

on open theFolders
repeat with i from 1 to length of theFolders
   my walkMe(item i of theFolders)
end repeat end open
on walkMe(nextFolder)
   try
       tell application "Finder" to set folderList to every item of nextFolder
       repeat with newFile in folderList
           if ((newFile as string) ends with ":") then
               walkMe(newFile)
           else
               tell application "Finder" to set name of newFile to (((name of newFile) as string) & ".mp3")
           end if
       end repeat
    try
end walkMe

: Okay, I've got an app that requires the mp3s to have a .mp3
: extension for it to read them. However a large number of the
: mp3 files in my music directory do not have the .mp3
: extension. Some do and some do not, they're all mixed
: together.
: How can I get the finder to open a folder and do the following:
: If it's a folder, leave it alone, if the file already has a
: .mp3 extension, leave it alone and if the file does not have a
: .mp3 extension, append one to the end of the filename.
: I'm really not all that good at applescript and it would be a
: waste of time for me to add .mp3 manually to every file.
: BTW I'm in mac os x running 10.1.3


One mans trash is another mans treasure


Filed under: Finder

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)