I'm trying to create a Numbers' document and then export it to pdf, but my main issue is that the document is created in iCloud and I cannot delete it. To make this new document at a custom location, I'm using make new document at, but I can't get the location specifier correct.
I tried to use a path:
set downloads to path to downloads folder
But I get an error, "can't make alias "path" to type location specifier". And if I try this:
set myDocument to make new document at end of downloads
I get another error Can't obtain alias "Users:username:Downloads"
I don't understand how I can simply create my document at a specific location...
You're mixing apples with oranges. The "location" here is merely the front-to-back position among other similar entities, such as documents / windows. You specify the path on disk when you save the document in a later step.
Related
I am trying to write a groovy script which obtains the source file location, I already tried using
SOurceDataStore.getLogicalSchema().getTechnology().getInternalName()
This only returns "FILE" technology that is being used.
If I wanted to obtain this path:
How can I achieve that?
Method getSchemaName() of class OdiPhysicalSchema can be used to retrieve the schema (or path for the file technology).
Now it looks like you want to retrieve it from a Datastore so you should first find the model, then the logical schema, then the physical schema linked to it through a specific context. You would need an IOdiContextFinder to get the OdiContext object. The code would be something like this :
context = ((IOdiContextFinder)odiInstance.getTransactionalEntityManager().getFinder(OdiContext.class)).findByCode("MY_CONTEXT");
filepath = SOurceDataStore.getModel().getLogicalSchema().getPhysicalSchema(context).getSchemaName();
In macOS, I want a folder action to trigger when I place a new file in that folder. The action should grab the filename, not including the path, and use that as the subject, and then attach the file to an email message and send it. Ideally, this would happen behind the scenes as I don't need to see the activity.
I created an Automator script that can grab the file, extract the name, create and send the file. But it's a bit of a kludge. Once I set a variable to the filename, I lose the attachment and have to get the finder item again. Also, it's not working as a Folder Action which is what I really need.
The Automator includes these steps:
Get Specified Finder Items
Get Folder Contents
Filter Finder Items -- I'm only interested in specific files
Set Value of Variable
--path
Run Shell Script -- extract only the filename without the extension
--basename "$#" .pdf
Set Value of Variable
--fileName
New Mail Message
--Subject: fileName
At this point I no longer can attach the specified file because Automator has 'lost' it, so I have to start over with the Get Specified Finder Items, Get Folder Contents, Filter Finder Items, Add Attachments to Front Message. Finally, Send Outgoing Messages.
What I want to happen is when I place a certain file into a directory, the Folder Action triggers, it looks at the file, and if it meets the filter criteria it emails the file, using only the filename without the extension as the Subject.
Create an Automator document type that is a folder action, and attach it to the desired folder. Items added to the specified folder will be passed on to the workflow, so you don’t need to use additional actions to get them.
You are already saving the filtered item paths in a variable, you just need to get them back for the Mail action:
Folder Action receives files added to { wherever }
Filter Finder Items
Set Value of Variable { Variable: path }
Run Shell Script
Set Value of Variable { Variable: fileName }
Get Value of Variable { Variable: path } (ignore input)
New Mail Message { Subject: fileName } (passed files are attached)
Automator workflows are designed to work with multiple input items as a batch; dealing with items one at a time would require a script or third party action such as Dispense Items Incrementally.
I'm trying to build a simple JavaScript for Automation script to add the currently playing track in iTunes to a particular playlist.
I have the playlist name stored as a string, var playlist.
The JXA Library add method says the following:
add method : add one or more files to a playlist
add list of file : the file(s) to add
[to: location specifier] : the location of the added file(s)
→ Track : reference to added track(s)
What I can't figure out is what to put for the [to: location specifier] part to specify a playlist.
I tried:
playlist = 'Queue'
iTunes = Application('iTunes')
iTunes.add(iTunes.currentTrack, {to: iTunes.playlists[playlist]})
But I get "Error -1708: Message not understood."
add doesn't do what you want here (add is used primarily for importing files outside of iTunes into the application, that's what the location specifier refers to).
You want to use the duplicate method on the track you want to "duplicate", copying it "to" the destination playlist. This code snippet works for me:
var iTunes = Application('iTunes');
var playlist = iTunes.playlists['Queue'];
iTunes.currentTrack().duplicate({to:playlist});
So I'm trying to make a data editor for an iOS/Android app I've got. There's 3 separate data files that I'd like to be able to edit, and I would like to save them to plist files or xml files. I'm planning on using Core Data in the app. The problems I'm running into:
1). Should this be a Document-Based Application or not?
2). If so, how would I set it up to allow editing of 3 different structures of files?
3). And if so, how would I go about setting the document based app to use regular plist/xml files as the file type instead of some custom file type?
The plan is for the editor to be able to open up and edit the files, and then the saved files can be copied into the project resources of the iOS and Android apps.
1. Should the app be document-based?
Yes.
2. How would one allow editing three different structures of files?
Choose from any of the following:
Create three dictionaries in the document types list, all three of which reference the same document class.
The same as above, but with windowNibName or makeWindowControllers choosing the UI depending on the document type. In other words, shared model code, but different view hierarchies. (I probably would choose either of the alternatives instead.)
Create three document type dictionaries, each of which has its own document class.
Which one you choose will depend on just how different the types are.
You'll probably want to export a UTI for each document type, as well. Xcode will not help you there; you'll need to write each UTI dictionary by hand.
3. How would I set the document based app to use regular plist/xml files as the file type instead of some custom file type?
If you export one or more UTIs, you should set the parent UTI(s) of each UTI appropriately, but that's advisory; all it means is you'll be able to open the documents with generic plist or XML editors/viewers.
Reading in and writing out the data is up to you, in each document class. You will have to use NSPropertyListSerialization, NSXMLParser, PRHXMLParser, NSXMLDocument, or something else, as you see fit; NSDocument does not handle your file format for you.
I create a new profile document with the following code:
Set doc = db.Createdocument()
doc.Form = "SMBPrivateProfile"
Call doc.Computewithform(True,True)
Call doc.Save(True, False)
But whenever I want to read a field by #GetProfileField i get an empty string, even if the field I want to read has a default value.
After opening & saving the document manually everything works.
Further details:
I improved an application and hit Application --> Replace Design.... The new version includes a new field within the profile document. When reading one of these new fields, the result is an empty string. When reading an 'old' field within the same document the result is the expected string.
e.g.:
MessageBox([OK];"Title"; #GetProfileField("SMBPrivateProfile"; "OLD_FIELD"; #ThisName))
--> Will result in: "This is a fancy old default value"
MessageBox([OK];"Title"; #GetProfileField("SMBPrivateProfile"; "NEW_FIELD"; #ThisName))
--> Will result in: "" (instead of "This is a fancy new default value")
That's not a profile document. To create profile document use:
db.GetProfileDocument("SMBPrivateProfile");
You can also add a second parameter for a unique key in addition to profile name.
Also consider if you really want to use profile documents. They are heavily cached and not visible in any views.
If I'm reading you right, it appears that you have updated a form and added a new field with a default value formula. You are then reading an existing document. When you do this, the new field that you added to the form does not yet exist. New fields and formulas aren't applied to existing documents until you do something to force them to be applied.
If it's a regular document (as your original code indicated), you can just open the document in the Notes client, edit, and re-save it. That will create the NEW_FIELD and give it its value. If there are lots of these documents, you could write a simple formula agent to do this via #Command([ToolsRefreshAllDocs]) or #Command( [ToolsRefreshSelectedDocs]).
If it is a profile document (as per the responce chain to #Panu's anser), then after you do the replace design you will have to write an agent to open the existing profile document using db.getProfileDocument use doc.ReplaceItemValue("NEW_FIELD";"new value").