Script works under Tiger but not Leopard

I have a script that worked perfectly under Tiger but now fails under Leopard. It still creates the folders but it does not copy the files. Any ideas what the problem is?

tell application "Microsoft Excel" to tell active sheet
	set L to value of used range -- get the search terms
end tell

set inputFolder to quoted form of POSIX path of (choose folder)
set destinationFolder to POSIX path of (choose folder)
repeat with i from 1 to count L
	set {keyword, newname} to items 1 thru 2 of item i of L
	-- search with find
	-- set foundFiles to paragraphs of (do shell script "find " & inputFolder & " -type f -name '*" & keyword & "*' ! -name '.*'")
	-- search with mdls
	set foundFiles to paragraphs of (do shell script "mdfind -onlyin " & inputFolder & " 'kMDItemFSName  = \"*" & keyword & "*\"'")
	set dest to do shell script "mkdir -v " & quoted form of (destinationFolder & newname)
	repeat with i in foundFiles
		try -- skips folders (only needed with the spotlight search)
			do shell script "cp " & quoted form of i & space & quoted form of dest
		end try
	end repeat
end repeat

Hi,

maybe you have installed a Scripting Addition in Leopard which has a reserved word keyword
this works in Leopard on my machine,
the copy task can be included in the find line and Spotlight can also search only for files


tell application "Microsoft Excel" to tell active sheet
	set L to value of used range -- get the search terms
end tell

set inputFolder to quoted form of POSIX path of (choose folder)
set destinationFolder to POSIX path of (choose folder)
repeat with i from 1 to count L
	set {keyword, newname} to items 1 thru 2 of item i of L
	set newDir to quoted form of (destinationFolder & newname)
	set dest to do shell script "mkdir -p " & quoted form of newDir
	do shell script "mdfind -onlyin " & inputFolder & " -0 'kMDItemFSName  = \"*" & keyword & "*\" && kMDItemKind != \"Folder\"' | xargs -0 -J {} cp {} " & newDir
end repeat

I tried the script you posted and applescript retrned the error:

“usage: cp [-R [-H | -L | -P]] [-fi | -n] [-pvX] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-pvX] source_file … target_directory”

this happens, when the literal string of the new folder (newname) ends with a slash.
You can avoid the error with an extra line


.
set {keyword, newname} to items 1 thru 2 of item i of L
if newname ends with "/" then set newname to text 1 thru -2 of newname
set newDir to quoted form of (destinationFolder & newname)
.

That line of code stopped the error. The script now just copies all the files from the source folders to the destination folder. It is not making the folders based on the Excel sheet or moving the files specified in the Excel sheet.