Jump to content

derekvan

Member
  • Posts

    24
  • Joined

  • Last visited

Everything posted by derekvan

  1. 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
  2. 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.
  3. 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?
  4. 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
  5. 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}"; }
  6. 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); }
  7. 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!
  8. 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.
  9. 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.
  10. 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
  11. 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.
  12. 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.
  13. 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.
  14. I created a file filter workflow on my desktop computer, where everything works as expected (I type "p" "space" "query" and get results from the correct folder). On my laptop, where Alfred is synced via Dropbox, the file filter does not return results--it presents the fallback search options. The file filter is set to a Dropbox path, so the path is the same on both computers. Will this type of workflow not sync? Is there some other procedure to follow? Thanks, Derek
  15. tsigo's fix is only partially working for me on Mavericks--is it still working for others? If nvAlt is not currently open, this workflow will open nvAlt, but not insert the search string. If nvAlt is currently open, the workflow works as expected: puts the search string in the omnibar of nvalt. Curious to hear if this is my problem, or if others are experiencing it as well.
  16. OSX 10.7.5 Alfred 2.0.2 (178) When I search for folders (by first pressing spacebar to enter file search mode), then highlight the search results, then press "return", the folder is opened up in the Finder. However, I have this option unselected in the preferences (I want the folder to be navigated in Alfred). I have checked and unchecked this option to try and reset it, to no avail.
  17. solved my own problem. Adapted the existing template workflow for opening image files in Safari. Really easy, but here it is if you just want to get going: http://d.pr/f/AwL8 Basically, if you search for a PDF, "Open in Skim" will be available as a file action. If you use it a lot, it will be the first one.
  18. Hi, I often use iTunes to control a set of airplay speakers in the evening. In the morning, I then try to use the mini-player to start some tracks to play through the computer speaker. However, because iTunes is set to use the airplay speakers, nothing happens. Is there some way to change the airplay device for iTunes via alfred? If not, could this serve as a feature request? Thanks! Derek
  19. Hi, When I search for and select PDF files within Alfred, I nearly always want to open them with the program "Skim." However, I don't set this at the OS level because when I just double click a PDF file (say, on the desktop), I'd rather have it open in Preview. So, is there a way to A) set PDF files to always open in a particular program via Alfred? or reorder the "Open With" results list by frequency of use rather than alphabetical? I know it's easy enough to simply type "sk" in the Open With list to filter to Skim, but easier yet to simply press "enter" when Skim is the first result because it is most used. Thanks! Derek
  20. Hi, I can't figure out how to add ~/Library/Scripts to the search scope so that these scripts show up in Alfred. When I press the + button, my ~/Library is hidden and I can't select it. I use TotalFinder and am able to view hidden files in the Finder, but I guess this doesn't transfer over? Am I missing something? Thanks! Derek
×
×
  • Create New...