title: How to use Applescript to create the same new file in all subfolders?
body: <p>I am looking to create a .DS_Store file (Mac) in every folder and subfolder where one does not exist, and then to lock every .DS_Store file both newly written and already existing, and then to set the modification date of each folder to the most recent item inside it.</p>
  <p>I've written the following code, which of course does not work. I'd appreciate some help getting this right.</p>
  <pre><code>set MyFolder to &quot;Macintosh Backup:Design Photos&quot;
  
  tell application &quot;Finder&quot;
      set SubFolders to every folder of entire contents of MyFolder
      repeat with xFolder in SubFolders
          set myFile to path of xFolder &amp; &quot;:.DS_Store&quot;
          if not (exists myFile) then
              make new file at xFolder with properties {name:&quot;.DS_Store&quot;}
          end if
          set locked of myFile to true
      end repeat
  end tell
  </code></pre>