Hi SG,
I think there is a situation when the name of a document doesn't show its file extension. Also, if the document has only one table the export command seems not to add the ".csv" extension to the name of the document. So, how about the following AppleScript?
set FD1 to choose folder with prompt "Choose the folder cotaining documents of Numbers.app"
set FD2 to (choose folder with prompt "Choose the destination folder to save csv files" default location FD1) as text
tell application "Finder"
set theDocList to (files of folder FD1 whose name extension is "numbers") as alias list
end tell
tell application "Numbers"
repeat with theItem in theDocList
set theDoc to opentheItem
set theDocName to theDoc'sname
if theDocName contains ".numbers" then
set thePath to FD2 & text 1 thru -9 of theDocName
else
set thePath to FD2 & theDocName
end if
if (count tables of sheets of theDoc) is 1 then
set thePath to thePath & ".csv"
end if
exporttheDoctofilethePathasCSV
closetheDoc
end repeat
quit
end tell
T2