Newbee help- script to compare filename prefix in 2 folders

I have two Folders with 1000+ files in each. They are audio files. Folder 1 contains AIF versions of the audio files. folder 2 contain mp3 versions of the files. Each folder contains files having a 5 digit prefix code, ala “12345_filename.mp3” and “12345_filename.aif” . I would like to construct an applescript that would check each file prefix in folder 2 against each file prefix in Folder 1 and report a list of filenames where matches were NOT found. Any help getting started would be appreciated.

Frank

Could you please verify whether or not the file names will match, other than their extensions, or it the matches will really only be the numeric prefix?

Michael:

Matches will really be only the numeric prefix. thanks

Frank

This should be relatively fast, even though the actual “difference of” algorithm used isn’t really efficient:


script serge
	
	property folder1 : missing value
	property prefix1 : {}
	
	property folder2 : missing value
	property prefix2 : {}
	
	property noMatch : {}
	
end script

-- debugging
--
set aifFolder to choose folder
set mp3Folder to choose folder

tell application "Finder"
	set serge's folder1 to ¬
		name of every folder of aifFolder whose name ends with ".aif"
	set serge's folder2 to ¬
		name of every folder of mp3Folder whose name ends with ".mp3"
end tell

set len1 to serge's folder1's length
set len2 to serge's folder2's length

repeat with i from 1 to len1
	set serge's prefix1's end to ¬
		serge's folder1's item i's text 1 thru 5
end repeat
repeat with i from 1 to len2
	set serge's prefix2's end to ¬
		serge's folder2's item i's text 1 thru 5
end repeat

repeat with i from 1 to len1
	set prefix to serge's prefix1's item i
	if (prefix is not in serge's prefix2) then ¬
		set serge's noMatch's end to serge's folder1's item i
end repeat
repeat with i from 1 to len2
	set prefix to serge's prefix2's item i
	if (prefix is not in serge's prefix1) then ¬
		set serge's noMatch's end to serge's folder2's item i
end repeat

return serge's noMatch

thank you, I will test this