Cleanup the result from a search script

How do I cleanup the result from this script:

property parentdir : "/Volumes/DTP/Leenbakker/orders"
do shell script ("find " & quoted form of parentdir & " -type d -maxdepth 1")
set Leenbakker to the result

set master_list to {}
repeat with i from 1 to (count of paragraphs of Leenbakker)
	copy paragraph i of Leenbakker to end of master_list
end repeat

set new_master_list to {}
repeat with this_master_item in master_list
	try
		set oldDels to AppleScript's text item delimiters
		set AppleScript's text item delimiters to "/"
		set theText to text item 5 of this_master_item
		if theText is not in new_master_list then copy theText to end of new_master_list
		set AppleScript's text item delimiters to oldDels
	end try
end repeat

The result is not cleaned
This is what I get:

tell current application
	do shell script "find '/Volumes/DTP/Leenbakker/orders' -type d -maxdepth 1"
		"/Volumes/DTP/Leenbakker/orders\r/Volumes/DTP/Leenbakker/orders/36744_voordeelbonnen_eindhoven\r/Volumes/DTP/Leenbakker/orders/36749_leenbakker sollicitatie\r/Volumes/DTP/Leenbakker/orders/36888_leenbakker\r/Volumes/DTP/Leenbakker/orders/37067_koofstreamer

What I want is for example only: 36744_voordeelbonnen_eindhoven

–Peter –

Peter:

I’m a bit confused as to what you’re doing here. You are setting a static parentFolder, then doing a search for folders i[/i] only in that folder. It appears you could just as easily accomplish what you’re doing with:

set parentFolder to choose folder -- This could be hardcoded too (though you lose the flexibility)
tell application "Finder" to set folderList to (name of every folder of parentFolder)

Then again. it is still pretty early for me. :stuck_out_tongue:

Cheers!
Jim Neumann
BLUEFROG

Thanks,

Both options (yours and mine) are ok.
I’m just used to do this by find and using maxdepth (easy to change, I have a complex and flexible search script to make)
I can not figur out how to get a final text file with a list of folders.
In my case :
Volumes/DTP/Leenbakker/orders/36888_leenbakker → in text file: 36888_leenbakker (or even better: 36888) - character 1-5 are leading.

Peter