I must be doing something wrong. I’ve written an action to export current draft to a file in iCloud. The action appears to be ignoring the file extension I put in the File/Name field. I’m trying to automate daily journal saving with Obsidian, and want the file name to look like:
[[date|%Y-%m-%d]].md
It expands the date properly, but the saved file name drops the extension. I even tried to hard-code the file name to Foo.md
and I see the same behavior.
You haven’t actually shown or shared what your action looks like, and there are a few ways you could have approached this.
This action works for me. I’ve included a prompt to show the expected file name in the format you indicate above, and then it saves the draft content to that file in the Drafts iCloud folder. Checking the file info, I can see it is a “.md” file.
Please review and try this action. See if it gives you the same results.
I build an action for this with the following script:
var lists = [".md", ".txt"];
var p = Prompt.create();
p.title = "select file type";
for (var list of lists) {
p.addButton(list);
}
var con = p.show();
if (con) {
let fileName = draft.processTemplate("[[safe_title]]" + p.buttonPressed);
let filePath = "/savedFiles/" + fileName;
let fmCloud = FileManager.createCloud(); // iCloud
fmCloud.writeString(filePath, draft.content);
}
else {
context.cancel();
}
Sorry, here’s the action:
The file gets saved as Foo
(without an extension, though it does allow me to add one in the save dialog), not Foo.md
.
That exports to “Foo.md” for me.
One more note for clarity: I’m exporting the draft explicitly to get around the sandboxing in iCloud. I moved my Obsidian vault to iCloud to work with the new beta iOS/iPadOS apps.
I have existing scripts that work for Dropbox and they work just fine.
What does the info look like on the file you generate? Here’s mine.
That exports to “Foo.md” for me.
Looks like it does include the extension for me on macOS. On iPadOS it gets dropped. Same on iOS.
Have you checked the file extension in the file’s info in the File app on iOS/iPadOS?
OK, now I see what was happening. When exporting from iPadOS it was hiding the extension. Sorry for the false alarm.
