Opening Randomized Images From Multiple Folders With Preview Application
Fixing and rewriting the code, particularly in the repeat with aFolder in theFolders loop, and using a handler from the accepted answer by Lri in Is there a simple way to shuffle a List in AppleScript? to randomize the list over your method, this now works.

I tested it on several different folders individually as well as multiple folders together, with as many as 500 JPG files in a test run.

tell application "Finder"
    if not selection is {} then
        set theFolders to selection as alias list
    else
        return
    end if
end tell

set theImages to {}
repeat with aFolder in theFolders
    set getImages to "find " &amp; aFolder's POSIX path's quoted form &amp; " -iname '*.jpg'"
    set tempList to paragraphs of (do shell script getImages)
    repeat with aItem in tempList
        copy aItem to end of theImages
    end repeat
end repeat

set randomImages to shuffle(theImages)

set filePaths to {}
repeat with thisFile in randomImages
    copy (thisFile as POSIX file as alias) to the end of filePaths
end repeat

tell application "Finder" to ¬
    open filePaths using application file id "com.apple.Preview"


### Handlers ###

on shuffle(input)
    script s
        property L : input
    end script
    set i to count of L of s
    repeat while i ≥ 2
        set j to random number from 1 to i
        set {item i of L of s, item j of L of s} to {item j of L of s, item i of L of s}
        set i to i - 1
    end repeat
    L of s
end shuffle