title: Applescript set window bounds for all windows
body: <p>I modified some AppleScript I found a while ago to position the frontmost window in a way so there is about a 10px margin on each side from the edge of the screen/dock/menubar:</p>
  
  <pre><code>set front_app to (path to frontmost application as Unicode text)
  
  tell application "Finder"
      set _b to bounds of window of desktop
      set scrn_width to item 3 of _b
      set scrn_height to item 4 of _b
  end tell
  
  tell application front_app
      activate
      set bounds of window 1 to {10, 35, (scrnWidth - 10), (scrnHeight - 80)}
  end tell
  </code></pre>
  
  <p>The problem is I have to do it for each window individually. I'd like to just run it once and have it work on all the windows of each application.</p>
  
  <p>I've tried modifying around 5 different scripts but just get errors. Here is what I have:</p>
  
  <pre><code>tell application "System Events"
      tell application "Finder"
          set _b to bounds of window of desktop
          set scrn_width to item 3 of _b
          set scrn_height to item 4 of _b
      end tell
      set _windows to get windows of (application processes whose visible is true)
      repeat with this_window in (items of _windows)
          set bounds of this_window to {10, 35, (scrn_width - 10), (scrn_height - 80)}
      end repeat
  end tell
  </code></pre>
  
  <p>Any help would be appreciated!</p>