Create and open NEW Pages document in specific folder


#1

hello,
It is very easy to open a specific file in a specific folder, but how do I create a new Pages document in a specific folder. That would save me having to create the Pages file and save it to a specific folder.
thanks very much for your time and help


#2

You should be able to do this with AppleScript. Search the forum, and the Internet, for "AppleScript Pages make document in folder".

For example:
https://iworkautomation.com/pages/document-save.html


#3

Create a default document and save it in a known location, eg:

~/Documents/Empty Pages Document.pages

Then use Keyboard Maestro’s Copy a File action to copy that document to wherever you want (renaming as necessary) and then open it.


#4

@JMichaelTX @peternlewis

Thanks very much to both of you.

I would prefer to use KBM macros instead of the ready made apple script for this one time, just so I become more proficient with KBM, and I would like to practise using Copy a File.

Let's say that:

Step 1- I create a series of empty documents in Pages, Numbers and a few other apps as per Peter's reply. I would do it once in Finder, not in KBM.
Step 2- I would use the KBM copy a file action to copy the file to one of perhaps 10 of my most commonly used folders which I would list in a conflict palette.
Step 3- I would then like to be prompted for a new file name and pass this name to the Copy a File action rename function.
Step 4- open the file.

I have difficulty and need help on
Steps 3 and 4: how do I create a prompt asking for a new name and pass it on to the rename function of Copy a file and open file action?
I just can't get it though my head about how to use variables, tokens and pass them on from one action to the next.

thanks very much for your time and help !


#5

Have you studied:

Anywhere in an Action there is a text field, you can use a Token or Variable, as in:
%Variable%NewFileName%

that you set in the Prompt Action.

Really, what you are asking is fairly simple and straight-forward. Rather than give you the answer, I gave you links to the info you need. Again, writing your own Macros, with a lot of trial and error, is the best way to learn.


#6

Here's another non-KM approach: Default Folder X

When the Open or Save dialog is open, DFX adds a right sidebar of Folders to select from.
As you know, I'm a huge KM fan/user, but I find DFX to be the better tool for this workflow.

You can do many things with DFX, including setting a default folder for each App.
I use the "Favorites" and "Recent Folders" collections the most.

DFX is also very scriptable.
BTW, Chris @ccstone and I are both big fans of DFX.


#7

Many and profuse thanks for all your suggestions, links and many thanks for taking the time to create your illustrations.
I will study the documentation and all the examples as you suggest, to try to get the concept of variables and tokens through my thick skull
I looked at and purchased DFX and it is indeed the absolute best solution to my problem. It answers all my needs and much more.
May I ask which screenshot app you use and which (I imagine the same app) you use to annotate images ?
thanks again VERY much !!


#8

@ronald, you are very welcome. I'm glad that DFX will work well for you.


#9

when I am in Pages, have entered the file name and chosen the folder in DFX, the first paragraph of my text is often file location followed by the path
This function does not exist in Pages.
Would you know if there is a quick way (with KBM or DFX) to copy the file path to the clipboard short of hiding Pages → calling up Finder (Pathfinder in my case), → go to the proper directory→ select file → context → copy path → copy → called up Pages again → paste in first paragraph
thanks again very much


#10

I don't understand what you are saying. When I test saving a file in Pages, and use a DFX folder, it works fine and I don't see any file info in the Pages document.

Maybe you could provide a screenshot?
An animated GIF would be even better showing the whole process.


#11

I apologize for my poorly formulated question.

The situation is the following: once I open a Pages file then rename it and place it in the appropriate directory using DFX thanks to your help, I make it a habit to start off my Pages document by writing a paragraph in which I write file location: followed by the path (see example below file location: file:///Users/ronald/Documents/Bills/water tax bill.pages). That way once the document is printed and filed, I can retrace it if need be at a later date to make modifications. See example below.

My problem is that once I am in Pages and typing my document I end up going through a tedious procedure to copy the path and paste it into the document : Pages → calling up Finder (Pathfinder in my case), → go to the proper directory→ select file → context → copy path → copy → call up Pages again → paste in first paragraph of document.

In other words, let's say that you are in Pages typing a document, and want to insert the document path into the document text what would you do ? is there any quicker way that the procedure listed above ?

thanks again

β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

Example : I create a Pages document which is a memo to my spouse about the water tax (she prefers hard copies)

β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

memo re water tax

file location: file:///Users/ronald/Documents/Bills/water tax bill.pages

we have to remember to pay the water tax every november
β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”


#12

Here is an AppleScript that should do the job. You can put it in a KM Execute an AppleScript action or call it from the Apple Scripts menu or from FastScripts:

tell application "Pages"
  set oDoc to document 1
  set posixPath to POSIX path of (get file of oDoc)
  tell oDoc
    set body text to body text & return & return & "file location:  file://" & posixPath & return
  end tell
end tell

Modify as needed to use the text/format you want.


#13

it works perfectly in Pages
thanks so much !!

  • I tried to duplicate the macro and change Pages for Numbers but it did not work.
  • sometimes I need the UNIX format file path. How would I modify the script accordingly.

sorry for the follow up questions, and thanks again


#14

I don't really use either Pages or Numbers, so I don't know the answer off the top of my head. The best way to figure out a solution for Numbers is to open the script in Script Debugger, and change the tell application to use Numbers.

Then you can use the SD tools to explore the Numbers objects and scripting dictionary.

Of course, I would probably start with a google search of "AppleScript Numbers file path"

Good luck. I'm sure you can figure this out. :smile:


#15

thanks very much !