I am building a script for Pages which will including setting the path to where a file is saved.
But in this script setting a variable to path to home folder, for example:
set pPath to POSIX path of (path to home folder)
does not go to the home folder, instead it goes to
In new (blank) script running the above gives:
If relevant: temporary Pages files are stored in an iCloud folder, and scripts also stored in an iCloud folder.
Any help would be appreciated to understand why within the Pages script the path to home folder
Relevant parts of the Pages script are (I have not reproduced all of it, as most of it is about formatting paragraphs, so not all the declared variables are shown, and as quoted here will not run without errors):
tell application "Keyboard Maestro Engine"
set AS_Date_prescribed_information_provided to getvariable "Date_prescribed_information_provided"
set AS_client_name to getvariable "client_name"
set AS_email_address to getvariable "email_address"
set AS_details to getvariable "details"
set AS_number_of_documents to getvariable "number_of_documents"
set AS_document_details to getvariable "document_details"
set AS_amount_of_notary_charge to getvariable "amount_of_notary_charge"
set AS_what_will_third_parties_be_providing to getvariable "what_will_third_parties_be_providing"
set AS_Charge_to_be_made_by_third_parties to getvariable "Charge_to_be_made_by_third_parties"
set AS_final_charge to getvariable "final_charge"
end tell
set PrescribedInformation to "Prescribed information"
set date_of_info to "Date"
set name_and_email_address_of_client to "Name of client and email address"
set vname to "Name: "
set email to "Email: "
set my_details to "My Details"
[... part of script deleted ...]
tell application "Pages"
activate
set thisDocument to ¬
make new document with properties {document template:template "Notary - basic template"}
tell thisDocument
set body text to PrescribedInformation & return & return & ¬
date_of_info & return & AS_Date_prescribed_information_provided & return & return & ¬
name_and_email_address_of_client & return & ¬
vname & AS_client_name & return & ¬
email & AS_email_address & return & return & ¬
my_details & return & return & ¬
services_that_I_provide & return & return & ¬
description_services & AS_details & return & ¬
number_of_documents & return & ¬
document_details & return & ¬
my_charge & return & ¬
what_3rd_are_providing & return & ¬
third_party_charge & return & ¬
total_charge & return & return & ¬
TandCs_and_about_charges_payments
[... part of script deleted ...]
end tell
end tell
end tell
tell application "Pages"
activate
-- as name of client contains first and middle names as well as last name
-- need to extract just last name which will always be last word in
-- variable AS_client_name
set last_name to word -1 of AS_client_name
-- make up filename from last name of client and prescribed information and date
set prescribed_information_filename_without_extension to last_name & " - prescribed information - " & theDate
-- to save files need to add extension to file name for pages and pdf
set prescribed_information_filename_with_pages_extension to prescribed_information_filename_without_extension & ".pages"
set prescribed_information_filename_with_pdf_extension to prescribed_information_filename_without_extension & ".pdf"
-- setting the path to where filenames are saved
-- set filepath to "Macintosh HD:Users:victor:vwdata:notary:2021:2021-prospective work:" as string
-- set filepath to "T7:Users:victor:vwdata:notary:2021:2021-prospective work:" as string
-- set filepath to "/Users/victor/vwdata/notary/2021/2021-prospective work/" as string
set filepath to (POSIX path of (path to home folder)) & "vwdata/notary/2021/2021-prospective work/"
-- setting a variables for file path and pages file and file path and pdf file
set pages_filepath_and_filename to filepath & prescribed_information_filename_with_pages_extension
set PDF_filepath_and_filename to filepath & prescribed_information_filename_with_pdf_extension
-- save the document as pages file and export as pdf
-- save thisDocument in file pages_filepath_and_filename
-- export front document to file PDF_filepath_and_filename as PDF
end tell
Model: iMac
AppleScript: 2.11
Browser: Safari 605.1.15
Operating System: macOS 12