title: Renaming files randomly with AppleScript isn't working
body: <p>I would like to take a directory's files and rename them by reassigning their existing filenames randomly among the same files.</p>
  <p>For example, if a directory had the following three files (name and file size):</p>
  <pre><code>filenameA   100KB
  filenameB   200KB
  filenameC   300KB
  </code></pre>
  <p>After running the script, it might look like this:</p>
  <pre><code>filenameB   100KB
  filenameC   200KB
  filenameA   300KB
  </code></pre>
  <p>So there would be 6 <a href="https://en.wikipedia.org/wiki/Permutation" rel="nofollow noreferrer">permutations</a> for three files, 24 for four files, etc….</p>
  <pre><code>tell application &quot;Finder&quot;
      tell application &quot;System Events&quot; to set theFiles to every file of folder &quot;/path/to/my/directory&quot;
      repeat count of theFiles times
          tell application &quot;System Events&quot; to set theFiles to every file of folder &quot;/path/to/my/directory&quot;
          set randint1 to random number from 1 to count of theFiles
          set randint2 to random number from 1 to count of theFiles
          set theName1 to name of item randint1 of theFiles
          set theName2 to name of item randint2 of theFiles
          set name of item randint1 of theFiles to &quot;randomname&quot;
          set name of item randint2 of theFiles to theName1
          set name of item randint1 of theFiles to theName2
      end repeat
  end tell
  </code></pre>
  <p>Running this code doesn't return any errors, however it doesn't work either.</p>
  <p>I hope it's clear what the script is supposed to do.</p>