• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Save/export attachment in Apple Notes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Save/export attachment in Apple Notes


  • Subject: Save/export attachment in Apple Notes
  • From: Mike Li via AppleScript-Users <email@hidden>
  • Date: Tue, 07 Jan 2025 17:26:27 -0800
  • Feedback-id: i17794915:Fastmail

Hi AppleScript users,

I am trying to write some AppleScript (or JXA) to get the attachment in Notes
to a folder. However, I am constantly encounter permission issues or expected
type errros.

function run(argv) {
  const folderName = "YOUR_FOLDER_NAME_HERE";
  const savePath = "/Users/yourusername/Desktop/";  // Adjust this path as
needed

  const Notes = Application("Notes");
  const app = Application.currentApplication();
  app.includeStandardAdditions = true;

  const blogFolder = Notes.folders.whose({ name: folderName })[0];
  const firstNote = blogFolder.notes()[0];

  let result = {
    noteName: firstNote.name(),
    attachmentSaved: false,
    savedPath: null,
    error: null
  };

  const attachments = firstNote.attachments();

  if (attachments.length > 0) {
    const firstAttachment = attachments[0];
    const fullSavePath = savePath + firstAttachment.name();

    try {
      firstAttachment.save(fullSavePath);
      result.attachmentSaved = true;
      result.savedPath = fullSavePath;
    } catch (error) {
      result.error = `Failed to save attachment: ${error}`;
    }
  } else {
    result.error = "No attachments found in the first note.";
  }

  return JSON.stringify(result, null, 2);
}


I also tried using const output = Path(...) and then run
firstAttachment.save({to: fullSavePath}); but still got type error.

Appreciate any help on how to export attachments in Apple Notes either through
AppleScript or JXA!

Thank!

Mike
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: Change color of selected text in front app's front window
  • Next by Date: Re: Save/export attachment in Apple Notes
  • Previous by thread: Re: Change color of selected text in front app's front window
  • Next by thread: Re: Save/export attachment in Apple Notes
  • Index(es):
    • Date
    • Thread