derekvan
Member-
Posts
24 -
Joined
-
Last visited
derekvan's Achievements
Member (4/5)
0
Reputation
-
solved Help with requesting user input on File Action
derekvan replied to derekvan's topic in Discussion & Help
Awesome! Thanks much for your help--that did it. -
Hello, I am trying to create a File Action that takes user input. This is an action that takes the selected PDF file in finder and changes the page numbers of the file (e.g., the PDF is of an article that starts on page 36 and this action would make it so that the PDF file doesn't start on 1, but on 36). If I hard code in the page number, the action works great for me as a bash script: python3 -m pagelabels --delete "$1" python3 -m pagelabels --startpage 1 --firstpagenum 251 "$1" However, I need to have a way to prompt for user input to add the page number (here, number 251). How can I add this? (you might be wondering, why don't I turn this action into a python script instead of a bash script. The answer is, I have no python experience. I'm just using a thing I found on GitHub that I was able to get working on the command line.) Here's the action itself: https://www.dropbox.com/scl/fi/hp8vohuqihme58ancud8e/PDF-Page-Numbers.alfredworkflow?rlkey=4drl8iffe06uciinr8zbqu68a&dl=0 edit: here's the link to the python command: https://github.com/lovasoa/pagelabels-py
-
date placeholder in file path not resolving
derekvan replied to derekvan's topic in Discussion & Help
I changed the workflow to have an "args and var" block before the "write text to file" block. I created a var "date" with the value {isodate}. Then in the write text to file block, I use this path: /Users/derekvan/Library/Mobile Documents/iCloud~md~obsidian/Documents/obsidian/dated/daily/{var:date}.md For some reason this works where the previous one didn't. Not sure I understand why, but this is resolved. -
I have the following path in a "write text to file" block: /Users/derekvan/Library/Mobile Documents/iCloud~md~obsidian/Documents/obsidian/dated/daily/{isodate}.md Instead of appending to the file for 2022-12-01.md, the action is creating a file called isodate.md What am I doing wrong?
-
Universal Action: Markdown to RTF Email
derekvan replied to derekvan's topic in Workflow Help & Questions
Thanks Vitor. I did originally start from Markdown Transform, but I couldn't figure out how to pass the text to the AppleScript in order to create the mail message--I thought pandoc might be an easier route, but it doesn't seem like it. I did find a clunky workaround using MarkdownTransform now after playing with it a bit. I can use your RTF conversion, then chain it to an AppleScript that creates a new mail message, then just send 4 tab keys and a cmd-V to paste the message into the body. I'd much prefer finding a way to send the RTF to the AppleScript directly, but I guess this works. https://www.dropbox.com/s/ujmq23zkgtz31fy/MarkdownTransform-derek.alfredworkflow?dl=0 -
I'm trying to create a universal action that will allow me to select some Markdown text and convert it to RTF in the body of an email message. From the debugger, it looks like I'm sending RTF to the clipboard ok (but I'm not certain) and it seems like the AppleScript to create the mail message isn't liking what's on the clipboard ... https://www.dropbox.com/s/t87xmx249x4i29l/MD>Email.alfredworkflow?dl=0 [16:50:35.703] ERROR: MD>Email[Run NSAppleScript] { NSAppleScriptErrorBriefMessage = "Expected \U201ctell\U201d, etc. but found identifier."; NSAppleScriptErrorMessage = "Expected \U201ctell\U201d, etc. but found identifier."; NSAppleScriptErrorNumber = "-2741"; NSAppleScriptErrorRange = "NSRange: {203, 7}"; }
-
I made some adjustments to the script to allow for searching multiple locations as well as multiple extensions. Thanks again @deanishe for helping out with the original script (which I never could have written but have just enough js knowledge to tinker with) #!/usr/bin/osascript -l JavaScript // Return list of files in folder with given extension. function findFiles(folder, extension) { let fm = $.NSFileManager.defaultManager, files = []; let root = $(folder).stringByExpandingTildeInPath; let contents = fm.contentsOfDirectoryAtPathError(root, null); for (let i = 0; i < contents.count; i++) { files.push(root.stringByAppendingPathComponent(contents.objectAtIndex(i))); } if (extension) files = files.filter(p => p.pathExtension.js == extension) return files; } // Convert NSString path to an Alfred feedback item. function alfredItem(path) { return { title: path.lastPathComponent.js, subtitle: path.stringByAbbreviatingWithTildeInPath.js, arg: path.js, uid: path.js, valid: true, type: 'file', icon: {path: path.js, type: 'fileicon'}, }; } function queryRegex(query) { let pat = []; let iter = query[Symbol.iterator](); let char = iter.next(); while (!char.done) { pat.push(char.value); char = iter.next(); } return new RegExp(pat.join('.*'), 'i'); } function run(argv) { let query = argv.length ? argv[0] : null; // Folder to search in var folder = '~/Downloads'; // Only show files with this extension var extension = 'epub'; let files = findFiles(folder, extension); var extension = 'mobi'; files = files.concat(findFiles(folder, extension)); folder = '~/Library/Mobile Documents/com~apple~CloudDocs/Downloads'; files = files.concat(findFiles(folder, extension)); var extension = 'epub'; files = files.concat(findFiles(folder, extension)); if (query) { let rx = queryRegex(query); files = files.filter(p => p.lastPathComponent.js.match(rx) !== null); } return JSON.stringify({items: files.map(alfredItem)}, null, 2); }
-
derekvan reacted to a post in a topic: Show all files of type in folder?
-
Perfect! Thank you.
-
Is it possible to create a workflow that will show all files of a certain type in a folder? I know I can create a file filter to allow me to search for files, but for this context I don't want to search. For example, I want to say: show me all the PDF files in the downloads folder (in Alfred rather than in the finder). Is that possible? Thanks!
-
This workflow is amazing. Thanks for sharing it! I am getting a few issues though. un : this command only sometimes creates a new sheet. Mostly it opens ulysses and does nothing else. I believe, but am not certain, that it will never create a new sheet in a group I have created, but will always create a new sheet if I select the "inbox" as the destination. uo : this command typically calls command-o to whatever app is open when I invoke it. Thus, it will work if Ulysses is already open, but not if some other app is open.
-
Tried this out a few times, and it looks like it works great. This workflow works great for me--no worries if you've not time to improve it! Thanks so much for making this small change for me. I was able to customize some elements of the script, but the sort mechanism is over my head.
-
Hi Stephen, I've finally gotten around to experimenting with your export script. It's amazing! With devonThink's new support of Markdown, this makes it easy to dump MD into DT. I've just got a question about customizing the sort in the script. Would it be possible to have the highlight's sorted by page number (instead of alpha or timestamp)? Thanks again for making these tools, and packaging them for easy use. Derek
-
File Filter not working on synced computer
derekvan replied to derekvan's topic in Discussion & Help
I just got it working. Turns out the file types were different on each computer. I dragged the files into the file type window on the workflow setup and now it's working fine on both computers. -
File Filter not working on synced computer
derekvan replied to derekvan's topic in Discussion & Help
I reindexed--no joy. Still not working. I can see the file filter as a result when i type "p" (the keyword i associated with it), but when I press space and the query, no results other than the defaults. -
File Filter not working on synced computer
derekvan replied to derekvan's topic in Discussion & Help
Yes, it is the same user name, for whatever that's worth. And I can find the file via Alfred or Spotlight just fine--that directory was already indexed. I created the file filter to reduce the number of false positives. But, I'll try to reindex just to make sure.