title: How do I create an apple script that changes the destination folder of airdropped files?
body: <p>I've downloaded the following apple script, which moves airdropped files to a specified folder (which I'll refer to as the Airdrop folder):</p>
  
  <pre><code>property AIRDROP_FOLDER : "Macintosh HD:Users:pschorn:Airdrop"
  property QUARANTINE_KEY : "59"
  
  property GET_QUARANTINE_COMMAND_START : "ls -l -@ '"
  property GET_QUARANTINE_COMMAND_END : "' | tr '\\n' ' ' | sed 's/.*com\\.apple\\.quarantine\\s*\\(\\d*\\)/ \\1/' | awk '{$1=$1};1'"
  
  on adding folder items to this_folder after receiving added_items
      repeat with i from 1 to length of added_items
          set current_item to item i of added_items
          set quarantine_type to getQuarantineType(POSIX path of current_item)
          if quarantine_type is equal to QUARANTINE_KEY then
              moveFile(current_item, alias AIRDROP_FOLDER)
          end if
      end repeat
  end adding folder items to
  
  on moveFile(move_file, destination_dir)
      tell application "Finder"
          move move_file to destination_dir with replacing
      end tell
  end moveFile
  
  on getQuarantineType(file_path)
      return do shell script GET_QUARANTINE_COMMAND_START &amp; file_path &amp; GET_QUARANTINE_COMMAND_END
  end getQuarantineType
  </code></pre>
  
  <p>I followed the instructions on this <a href="https://www.idownloadblog.com/2017/03/03/change-airdrop-destination-folder-mac/" rel="nofollow noreferrer">website</a> to set it up as a folder actions script. </p>
  
  <p><strong>However, if I move an airdropped file out of my newly created airdrop folder and back into my downloads folder, it gets automatically put BACK in the airdrop folder.</strong> I don't want this to happen.</p>
  
  <p>I found that after applying this terminal command <code>xattr -d com.apple.quarantine [file path of airdropped file]</code>, the file will no longer get moved back into my airdrop folder after I move it out.</p>
  
  <p><strong>MY question is: How do I integrate this command into the above apple script so that the airdropped files do not automatically get moved back to my airdrop folder after I move them out of it?</strong></p>
  
  <p>One way to do this might be to set up another folder action script that removes the quarantine attribute from all files that are placed into my airdrop folder using the aforementioned terminal command.</p>
  
  <p>EDIT: <strong>HERE IS THE SOLUTION!!!</strong> CREDIT: @Oantby</p>
  
  <pre><code>property AIRDROP_FOLDER : "Macintosh HD:Users:pschorn:Airdrop"
  property QUARANTINE_KEY : "59"
  
  property GET_QUARANTINE_COMMAND_START : "ls -l -@ '"
  property GET_QUARANTINE_COMMAND_END : "' | tr '\\n' ' ' | sed 's/.*com\\.apple\\.quarantine\\s*\\(\\d*\\)/ \\1/' | awk '{$1=$1};1'"
  
  on adding folder items to this_folder after receiving added_items
      repeat with i from 1 to length of added_items
          set current_item to item i of added_items
          set quarantine_type to getQuarantineType(POSIX path of current_item)
          if quarantine_type is equal to QUARANTINE_KEY then
              clearQuarantineFlag(POSIX path of current_item)
              moveFile(current_item, alias AIRDROP_FOLDER)
          end if
      end repeat
  end adding folder items to
  
  on moveFile(move_file, destination_dir)
      tell application "Finder"
          move move_file to destination_dir with replacing
      end tell
  end moveFile
  
  on getQuarantineType(file_path)
      return do shell script GET_QUARANTINE_COMMAND_START &amp; file_path &amp; GET_QUARANTINE_COMMAND_END
  end getQuarantineType
  
  on clearQuarantineFlag(file_path)
      do shell script "xattr -d com.apple.quarantine '" &amp; file_path &amp; "'"
  end clearQuarantineFlag
  </code></pre>