Newbie script question

Hello - I am a newbie to scripting, and am turning to it to help me with a task which seems like it should be easy to automate:

I have 2 folders on a networked file system, called them ’ FLAC’ and ‘MP3.’ As you might guess, FLAC holds all music ripped as FLAC (as subfolders by artist, then album), and MP3 holds all music ripped as MP3 (ditto) they are actually on different shares, for reasons unimportant for this post.

Here’s my question - how can I write a script which will regularly (say weekly), go through the FLAC folder and convert any file found in this folder, but not in the MP3 folder into MP3 format?

I am using utility “XLD” for any and all file conversion.

Any thoughts, scripts, pointers, etc. welcomed!

G New

Model: iMac, READYNAS NV+, OS 10.6.3
Browser: Firefox 3.5.7
Operating System: Mac OS X (10.6)


I have no idea about XLD but this might be a point to start.
If it’s monday and the flac folder is not empty it converts all files in the flac folder,
then moves them to the mp3 folder and deletes the flac files.
In the doConversion handler you can add the XLD code

Hope it helps

property mp3Folder : "disk:path:to:mp3Folder:"
property flacFolder : "disk:path:to:flacFolder:"

tell application "Finder" to set isEmpty to (count folder flacFolder) = 0
if weekday of (current date) is Monday and not isEmpty then
	tell application "Finder" to set flacList to files of folder flacFolder
	repeat with oneFile in flacList
		doConversion(oneFile as alias)
	end repeat
	tell application "Finder"
		move (files of folder flacFolder whose name extension is "mp3") to folder mp3Folder
		delete files of folder flacFolder
	end tell
end if

on doConversion(theFile)
	-- do the conversion
end doConversion

Hi - thanks alot for your suggestion. However, what I was looking for was to keep the Flac files (eg, to be used as backup and high end audio). When I typically rip files, my tagging program will place the files in a Flac subdirectory according to artist and album. So, I believe something has to keep track of the flac directory structure.

I also just noticed that some mp3 files have not been converted correctly. The files sizes are miniscule, which would indicate that only the header was written. Would anyone be able to share a script which would trawl a directory and return all files smaller than a specified size?