file names to text file problem

Hi all,

I tried to do a script that copies files to another folder and changes the size if neccessary. That works. But I need another routine in my scipt. I need a textfile with all filenames and a specific list delimiter.
There has to be counter for the files included.

This is my test and the result:

on run
	set Image_folder to "Festplatte:Users:Shared:Screenbilder:JPEG Images"
	ListContents(choose folder Image_folder)
end run


on ListContents(theFolders)
	set itemNumber to 1
	set LogFile to a reference to (path to desktop as string) & "picID"
	set savedTextItemDelimiters to AppleScript's text item delimiters
	repeat with i in (theFolders as list)
		set foo to "&pic" & itemNumber & "="
		set itemNumber to itemNumber + 1
		set AppleScript's text item delimiters to "&pic" & itemNumber & "="
		tell application "Finder" to set foo to foo & (name of files of (i) as list) & return as text
	end repeat
	try
		open for access file LogFile with write permission
		set eof of file LogFile to 0
		write foo to file LogFile
		close access file LogFile
	on error errText number errNum
		close access file LogFile
		display dialog errText
	end try
	set AppleScript's text item delimiters to savedTextItemDelimiters
end ListContents

Result:
&pic1=bild1.jpg&pic2=bild2.jpg&pic2=bild3.jpg&pic2=bild4.jpg

As you can see my script does 1 and 2 but no more counts for the pic-prefix.

Can anybody help me?

Thanks
Sabine

Try this:

property imageFolder : "Festplatte:Users:Shared:Screenbilder:JPEG Images:"
property logFile : (path to desktop as text) & "picID"

on run
	ListContents(choose folder default location (alias imageFolder) with multiple selections allowed)
end run

on ListContents(theFolders)
	set foo to {}
	
	repeat with thisFolder in theFolders
		set temp to {}
		
		tell application "Finder" to set names to name of files of thisFolder
		repeat with i from 1 to (count names)
			set temp's end to ("&pic" & i & "=" & (item i of names))
		end repeat
		
		set foo's end to temp as text
	end repeat
	
	set ASTID to AppleScript's text item delimiters
	set AppleScript's text item delimiters to (return)
	set foo to foo as text
	set AppleScript's text item delimiters to ASTID
	
	try
		open for access file logFile with write permission
		set eof of file logFile to 0
		write foo to file logFile
		close access file logFile
	on error errorMsg number errorNum
		close access file logFile
		display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "Cancel" default button 1 with icon caution
	end try
	return foo
end ListContents

My result:

Thank you Bruce,
is seems to work. Great.
Sabine