Slow script to get file names

Hi all

I update some script and it is very slow I see now with a folder with a lot of files.
It return all Excel files and I use that in VBA code to open and do some stuff

set OSAConverter to “osascript -e ‘on run argv
return posix file (item 1 of argv) as string
end run’ {} \;”
do shell script "find -E ‘/Users/RDB/Desktop/TestMacFolder’ -iregex ‘./[^~][^/]\.(xls|xlsx|xlsm|xlsb)$’ -maxdepth 3 -exec " & OSAConverter

Thanks for looking at it


I think I recall that using the ‘-exec’ option with ‘find’ is famously slow. The script below is certainly a lot faster. It does the conversions to HFS paths entirely with vanilla applescript after ‘find’ has returned the POSIX paths:

set foundPaths to paragraphs of (do shell script "find -E '/Users/RDB/Desktop/TestMacFolder' -iregex '.*/[^~][^/]*\\.(xls|xlsx|xlsm|xlsb)$'  -maxdepth 3")

repeat with thisPath in foundPaths
	set thisPath's contents to (POSIX file thisPath) as text
end repeat

set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to return
set foundPaths to foundPaths as text
set AppleScript's text item delimiters to astid


Thanks Nigel

Go check it out today.
Thanks for your time, much appriciated

Thanks Nigel, working much faster now; also in VBA.

have a nice weekend