sync and scan subfolders

Hi all of you,

I kindly ask for help.
I have got 3 Folders
every folder named:

number_name (example: 1111_ABC)
The name never change. The numbers do it, like 1234_ABC or 6543_ABC.

I put a folder (1234_ABC) in the Temp-folder
The Script scan the Main-folder about the name (not the number).
If there is a folder with this name (4567_ABC), the script move this in the Archive-folder an put the new folder (1234_ABC) in the Main-folder.

This script below do this, but it can’t scan subfolders and proceed this moves.

When the Folderstructure like this:

ABC (Mainfolder)
-4567_ABC (Subfolder)

The script can’t move the Folder 4567_ABC
Only in the first Folder Level.

I need a modification of my script which will scan subfolders, too an proceed the moves.

thanks a lot
sunny



tell application "Finder"
	
	set startPfad to ":Users:name:Desktop:TEMP:" as alias
	set zielPfad to ":Users:name:Desktop:Main:" as alias
	set archivPfad to ":Users:name:Desktop:Archiv:" as alias
	
	
	set zielNamen to {}
	set AppleScript's text item delimiters to {"_", "."}
	set zielOrdner to name of folders of zielPfad
	set startOrdner to name of folders of startPfad
	repeat with i in startOrdner
		repeat with j in zielOrdner
			if (text item 2 of i) = (text item 2 of j) then
				set AppleScript's text item delimiters to ""
				set archiv to "mv '" & POSIX path of zielPfad & j & "' '" & POSIX path of archivPfad & j & "'"
				do shell script archiv
			end if
		end repeat
		set AppleScript's text item delimiters to ""
		set mv to "mv '" & POSIX path of startPfad & i & "' '" & POSIX path of zielPfad & i & "'"
		do shell script mv
	end repeat
end tell