Newbie: Compare folders and label files that are different

I’m absolutely new to Applescript and I have a question:

Example: Folder 1 has 150 files, Folder 2 has the same 150 files plus some additional files.

I would like to compare the two folders and have the additional files labeled, so I can filter
for new/different files.

Do I need Applescript or can I work with Automator?

Any help is appreciated, thnx

Eric

Eric,

This is crude but will get you started.

set fold1 to choose folder with prompt "Choose first folder to compare."
set fold2 to choose folder with prompt "Choose second folder to compare."
tell application "Finder"
	set f1Files to every file of folder fold1
	set f2Files to every file of folder fold2
	repeat with anItem in f1Files
		set thisItem to anItem as alias
		if thisItem is not in f2Files then
			set label index of thisItem to 5
		end if
	end repeat
end tell

This script will change the label of any items in fold1 that are not in fold2. Note that this disregards any other folders that may be inside each folder. If you have folders within and files to compare inside those folders you’ll need a recusion script (a handler that calls itself until certain conditions are met -no more folders.).

Hope this helps. As far as Automator is concerned, I haven’t a clue. I haven’t used Automator at all.

PreTech

Wow, that was quick! Thnx for thinking with me so far.
However, I tried the script:

-duplicated a folder for the test
-added some extra files in Folder 1
-ran the script
-pointed out the folders
(so far so good)
-EVERY item in folder 1 was labeled

Do I need to make some adjustments, maybe select the folder with the fewest items first?

Eric

Try this with folder 1 containing the extra items

set fold1 to choose folder with prompt "Choose first folder to compare."
set folderPath to fold1 as string
set fold2 to choose folder with prompt "Choose second folder to compare."
tell application "Finder"
	set f1Files to name of every file of folder fold1
	set f2Files to name of every file of folder fold2
	repeat with anItem in f1Files
		if anItem is not in f2Files then
			set anItem to alias (folderPath & anItem)
			set label index of anItem to 5
		end if
	end repeat
end tell

Thanks, Jacques.

Much nicer than my version; I like the folder switch.

j

@Jaques,
absolutely great, this little script does exeactly what I need!

@PreTech and capitalj
Thanx for helping! Realy appreciate it!

Eric