insert filename into footer

Hi Everyone,


Can you tell me if it's possible to insert a filename into a footer in Pages, so that the filename and it's directory path is shown when you print it?


Cheers 🙂

MP, Mac OS X (10.5.6), null

Posted on Oct 22, 2018 7:50 AM

Reply
Question marked as Top-ranking reply

Posted on Oct 23, 2018 2:18 AM

Not directly from the Pages application.


Whether in a custom template, or current document, you can enter the string "[Filename]" without the quotes just once in the footer of the first page where you want the filename to appear. Select all of that string, and from the Format menu : Advanced, select Define as Placeholder Text. The text will become salmon colored to confirm this, on every page of the section where you entered this footer text. If subsequent sections match the previous section, then on all pages of your document.


To replace every occurrence of that Placeholder text with the document name, after you have satisfied paragraph one, you would need to run the following AppleScript, which you can copy/paste into Script Editor (Dock : Launchpad : Other : Script Editor). Click the hammer icon, and then click run to see your document name inserted into every footer.


set nameStr to "[Filename]" -- placeholder text in footer of document


set theseTags to {}


tell application "Pages"

tell front document

activate

set theName to name of it

set theseTags to the tag of every placeholder text whose tag is equal to nameStr

repeat with i from 1 to count of theseTags

set thisTag to itemi of theseTags

set (every placeholder text whose tag is thisTag) to theName as text

end repeat

end tell

end tell

return

This was tested on Pages v7.2 on High Sierra 10.13.6 (17G65). It should work just fine on Mojave too.

2 replies
Question marked as Top-ranking reply

Oct 23, 2018 2:18 AM in response to slaterk

Not directly from the Pages application.


Whether in a custom template, or current document, you can enter the string "[Filename]" without the quotes just once in the footer of the first page where you want the filename to appear. Select all of that string, and from the Format menu : Advanced, select Define as Placeholder Text. The text will become salmon colored to confirm this, on every page of the section where you entered this footer text. If subsequent sections match the previous section, then on all pages of your document.


To replace every occurrence of that Placeholder text with the document name, after you have satisfied paragraph one, you would need to run the following AppleScript, which you can copy/paste into Script Editor (Dock : Launchpad : Other : Script Editor). Click the hammer icon, and then click run to see your document name inserted into every footer.


set nameStr to "[Filename]" -- placeholder text in footer of document


set theseTags to {}


tell application "Pages"

tell front document

activate

set theName to name of it

set theseTags to the tag of every placeholder text whose tag is equal to nameStr

repeat with i from 1 to count of theseTags

set thisTag to itemi of theseTags

set (every placeholder text whose tag is thisTag) to theName as text

end repeat

end tell

end tell

return

This was tested on Pages v7.2 on High Sierra 10.13.6 (17G65). It should work just fine on Mojave too.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

insert filename into footer

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.