Jump to content

TomBenz

Member
  • Posts

    299
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by TomBenz

  1. Thanks Stephen. I was using "Reveal in Finder". Now destination folder is opening up as I have used {var:newBaseFolder} in Open File action. Selecting moved files at destination would have been ideal but this will be for future :)

  2. On 10/17/2023 at 3:56 AM, exposition said:

    Thank you very much for all of your hard work, @Stephen_C!

    @Stephen_C hi Stephen, this is a great workflow to move files to new folder.

     

    I would like to use this as base and see if I can create new workflow that moves selected files to destination (existing or new folder) and then open the new location with moved files selected at this location. Is this feasible? Pls guide

  3. On 6/8/2023 at 9:34 PM, jdb said:

    Refactor released here https://github.com/johandebeurs/alfred-mstodo-workflow/releases/tag/0.2.0 and on Packal. Still pending MS graph endpoint refactoring but Py3 refactor is largely done

    @jdb Request you to look into this issue @vitor

     

    https://github.com/johandebeurs/alfred-mstodo-workflow/issues

     

    On MacOS Sonoma, I'm getting the following error when trying to setup td worflow. This also happens when running _td-full-reset and _td-reset.

    Here's my settings from ENV

     ➜  ~ which -a python3
    /opt/homebrew/bin/python3
    /usr/bin/python3
  4. 21 minutes ago, Stephen_C said:

    I'm clearly missing something but, surely, outside Alfred (e.g., in Finder) ⌘P and pressing the spacebar respectively (i.e., no need for Universal Actions)? Inside Alfred (i.e., looking at Alfred's results) see Alfred Preferences → Features → Previews.

     

    Stephen

    Thanks for your reply. Print command doesn't give option to print only selected text in outlook / safari etc. Got this code and Alfred workflow with universal action to achieve my desired outcome.

     

    tell application "System Events"

    keystroke "c" using {command down}

    end tell

     

    tell application "TextEdit"

    activate

    set newDoc to make new document

    tell application "System Events" to keystroke "v" using command down

    delay 0.2

    activate

    -- Ask the user if they want to print before closing

    set printResponse to display dialog "Do you want to print the document before closing?" buttons {"Print", "Don't Print"} default button "Print"

     

    -- Check the user's response

    if button returned of printResponse is "Print" then

    print front document without print dialog

    end if

     

    set saveResponse to display dialog "Do you want to save the document before closing?" buttons {"Save", "Don't Save"} default button "Don't Save"

     

    -- Check the user's response

    if button returned of printResponse is "Save" then

    set desktopPath to path to desktop folder as text

    set rtfFileName to "temp_text.rtf"

    set rtfFilePath to desktopPath & rtfFileName

    save front document in file rtfFilePath

    end if

     

    -- Close the document without saving it again

    close window 1 with saving

    end tell

  5. 1. Is there a workflow that can be used to manually trigger, list all printer, select and change default printer?

     

    2. Is it possible to go further to set it based on office or home wifi network. Request to share your experience on this or guide. I got below from chatGPT:

     

    Changing the default printer based on your network location (home or office) can be automated on a macOS system using a combination of AppleScript, shell commands, and Location-aware settings. There isn't a direct built-in feature in macOS to automatically switch printers based on network location, but you can achieve this through a somewhat manual setup using network locations in System Preferences and running scripts when these locations change.

    Setting Up Network Locations

    1. Create Network Locations:
      • Go to Apple Menu > System Preferences > Network.
      • Click the Location drop-down menu at the top and choose Edit Locations.
      • Use the "+" button to add new locations, naming one "Home" and another "Office" or as per your preference.
      • Configure the network settings for each location as needed, such as Wi-Fi network SSID, and then switch between them as you move between your home and office.

    Script to Change Default Printer

    You can write an AppleScript or shell script to change the default printer. Here's a simple example of how to do it in AppleScript:

     
    applescriptCopy code
    -- AppleScript to set the default printer set currentLocation to "Home" -- or "Office", you can automate this part by detecting the network SSID if currentLocation is "Home" then set defaultPrinter to "Home_Printer_Name" -- Replace with your home printer's name else if currentLocation is "Office" then set defaultPrinter to "Office_Printer_Name" -- Replace with your office printer's name end if do shell script "lpoptions -d " & defaultPrinter

    Automating the Process

    Automating this process involves detecting when your network location changes and then running the appropriate script. This can be more complex, as macOS does not provide a direct way to trigger scripts on network location changes. However, you can use third-party tools or create a custom solution to monitor network changes and trigger the script.

    1. Third-Party Automation Tools: Tools like Keyboard Maestro or Hazel can be configured to run scripts based on certain triggers, such as connecting to a specific Wi-Fi network.

    2. Custom Solution: Write a daemon or use launchd to periodically check the current Wi-Fi SSID or network location and run the AppleScript to switch the default printer accordingly. This requires a more advanced understanding of macOS scripting and system configuration.

    Steps for a Custom Solution

    1. Write a script that checks the current network SSID using a shell command like networksetup or by parsing system logs.
    2. Use launchd to run this script at regular intervals or upon network changes.
    3. The script then determines the location (home or office) based on the SSID and runs the appropriate AppleScript to change the default printer.

    Note

    This solution requires a bit of setup and possibly learning more about macOS scripting and automation. Depending on your macOS version, some commands or steps might differ, and you may need administrative privileges to change network settings or add launchd tasks.

    For more detailed instructions or help with scripting, you might consider looking into macOS scripting communities or forums, as well as the official AppleScript and launchd documentation.

     

     

  6. On 4/3/2019 at 3:26 AM, MrAu said:

    Hi,

     

    This workflow adds a File Action to allow for sending a document to your default printer.

    Eg: send a document to printer, print selected files.sRT352g(1).png.d27726fe0fede376a1d723166a0cab4e.png

     

    It takes an Automator workflow OWewDFN(1).png.18c44439667d6c170b7c776368c60565.png

     

    and runs it like so DkPQSe7(1).png.e6f7f3fa71e7ae5f9934180ee2994c40.png

     

        /usr/bin/automator ./print-selected.workflow

     

    download here https://github.com/fxjkhr/alfred-workflows/blob/master/print-selected.alfredworkflow

    @vitor @Vero Is there a universal action that prints selected content in any application to default printer or open in preview?

  7. On 11/7/2023 at 6:07 PM, chrislemke said:

    Dear Alfred Community,

    I am writing to share an important update about the ChatFred project.

    As the project has grown and evolved, it has been a privilege to work with all of you. Your contributions and feedback have been invaluable, and together, we've built something truly special. However, due to an increasingly demanding schedule, I am no longer able to dedicate the necessary time to maintain ChatFred with the justice it deserves.

    The advent of numerous advancements from OpenAI has opened up exciting new possibilities for ChatFred, marking a perfect moment for fresh energy and leadership to take the helm. Therefore, I am in search of someone with the passion and expertise to carry forward this legacy.

    If you have a strong interest in the project and believe you have what it takes to lead it into its next chapter, please reach out. Your role would involve steering development, managing the community, and integrating the latest AI technologies to keep ChatFred at the forefront.

    I am optimistic about the future of ChatFred under new stewardship and look forward to seeing it continue to thrive. Please direct inquiries and expressions of interest to the contact information listed below.

    Thank you for your understanding and continuous support.

    Best regards,

    Chris

     

    BTW: This text was written by ChatFred 😉

     

    Has somebody else taken up further development of ChatFred?

  8. On 10/21/2023 at 1:09 AM, joshuadwagner said:

    I just created a workflow that uses Applescript to switch folders in Outlook. @giovanni, If you (or anyone) would like to incorporate it into something else, you're welcome to do so. I'm afraid that this is about the extent of my abilities so I may not be of much help with issues.

    https://github.com/joshuawagner/alfred-go-to-Outlook-folder/releases/latest

     

     

    This is very good and useful. Thank you for sharing. 

     

    Is it possible to also navigate to Groups or Smart Folders in similar manner?

  9. On 9/18/2022 at 10:25 PM, Acidham said:

    Should be available in v1.4.

     

    Select Search&Add

     

    1299587725_Screenshot2022-09-18at18_54_49.thumb.png.0807330335c13fc21d34894cb4f4377a.png

     

    @Acidham is it possible to add a destination folder by navigating to it? I have excluded this location from indexing so search and add don't work. I would like to use universal action to select the source and then navigate to the destination on a non-indexed location on iCloud to add as the destination. 

  10. thank you @vitor

     

    I could download .vtt file without downloading video with yt-dlp.

     

    To download only the .vtt subtitle file without downloading the video itself using yt-dlp, you can use the following command:

     

    yt-dlp --write-subs --sub-format "vtt" --skip-download "https://www.youtube.com/watch?v=N45KtLPcRS8"
     

    This command tells yt-dlp to:

    • --write-subs: Download subtitles.
    • --sub-format "vtt": Specify the subtitle format as .vtt.
    • --skip-download: Skip downloading the video itself, only download the specified subtitles.

    Replace "https://www.youtube.com/watch?v=N45KtLPcRS8" with the URL of the YouTube video from which you want to download the subtitles.

  11. On 1/18/2022 at 3:04 AM, vitor said:

    You’re still thinking in terms of Excel. Forget about that. Don’t describe your steps, describe the data you have as input (where you get it from) and what you want to have in the end.

     

    @vitorIs it possible to download Youtube video transcript in vtt or SRT file format? i.e. you tube video transcript download as an added option to YouTube video download? 

  12. @Acidham I love this workflow and use it for backup. Request for some info on it:

     

    1. rsync_log lists files getting added or deleted during the sync process. How are these identified? I sometimes get files that have stayed the same during the incremental backups. It will be good to understand this better

    2. Is rsync_log storing the last sync time somewhere or does it create a complete rsync list by comparing source and destination fully? How much time should this step typically take for 50/100 GB of data?

    3. I am using rsync to do a backup of OneDrive to iCloud. OneDrive files are not always on disk (even after marking it to download all) so build the list takes a long time. Is it the reason for the long time to generate file list? Is anybody using using OneDrive and facing challenges in keeping all files local?

     

     

  13. 10 hours ago, sepulchra said:

    Thanks @vitor. That is much much cleaner and instructive. I didn't put it on github as I didn't know if it would be of value beyond being an example to the wider community. In essence everytime i start a new project with its own set of folders, I would replicate this and created the specific folder paths etc. Look how much cleaner this looks:

    image.thumb.png.e8e16bbcbc42a4e1dd4d568f70fac805.png

     

    I never have used the split argument object and it works as I have configured it, but is this how it "should" be?

    image.png.e6e3752e55a6ba015249dcfdadc59027.png

    Pls share updated version via Github. Many thanks in advance

  14. On 10/12/2023 at 2:46 AM, royaljerry said:

    I have updated my project creator workflow with Python 3.x, which creates a folder structure defined in a text file. This post is an update from my 10 years old entry.

     

    Prerequisites

    • Python 3.x
    • Alfred Powerpack

    Usage

     

    Create an UTF-8 encoded text file – the definition file, select it in Finder (or any file manager app), get Alfred actions panel (with the hotkey set in Preferences → Features → Universal Actions → Selection Hotkey), and run RJ: Create Project. The folder structure will be created where the definition file resides.

     

    image.thumb.png.95262152f93a18eba1a0748f608656c3.png

     

    Syntax

    • One line represents a folder.
    • Lines on the same indention level represent sibling folders.
    • A positive indention to the previous line represents a subfolder.
    • A negative indention to the previous line represents a parent folder.
    • Indentions must be written with TAB characters.
    • The script will replace the %date% string in the definition file with the actual date.

     

    Example 1

     

    Contents of the definition file:

     

    root-folder-1
    root-folder-2
    	sub-folder-1
    	sub-folder-2
    	sub-folder-3
    		sub-sub-folder-1
    		sub-sub-folder-2
    	sub-folder-4
    root-folder-3

     

    Example 2

     

    Contents of the definition file:

     

    root-folder-1
    root-%date%-folder-2
    	sub-folder-1
    	sub-folder-2
    		sub-sub-%date%-folder-1
    		sub-sub-folder-2
    	%date%
    root-folder-3

     

    Downloads

     

    RJ: Create Project

     

    GitHub

     

    Project GitHub Page

     

    Very nice and simple. 

  15. On 9/30/2023 at 8:34 PM, zeitlings said:

     

    You pass the variables on to a script, for example, like so:

    ./scripts/highlight.py "$loc" "$1" "$docx"

     

    Btw., I found that the example you posted is quite flawed. Only the last sentence of a paragraph that contains a keyphrase will be highlighted as with each loop, the entire work that is done previously gets erased. With this fixed, each sentence containing a keyword is highlighted; the downside then is that you are likely to encounter large chunks of highlighted text. At this point the script forfeits it's usefulness as the desired result is a document with highlighted key sentences. One approach would be to drastically lower the keyword count... or to process really large docx-files. To find out which sentences are really important would require more NLP though.

     

    Anyway, I went down the rabbit hole for you: Alfred-Workflow.

     

    You will want to play with "highlight.py" a bit. There are three methods you can test:

    highlight_keywords to highlight all the keywords.
    highlight_sentences to highlight all sentences containing a keyword.
    highlight_original to highlight in the flawed fashion described above.

     

    Sure made for an interesting Saturday... 😅

     

     

    Many many thanks @zeitlings for your inputs and time on this. I will experiment with highlight.py and revert in few days.

  16. 15 hours ago, zeitlings said:

    Hey @TomBenz, that sounds like a job for a different workflow and somewhat niche.

    If you want to adapt the workflow to do that, I'd start with passing (a) the text file location $loc and (b) the keywords, i.e. the query as $1 for zsh argv to a “Run Script” object that runs your python script.

     

    The script should look something like this (not at all tested):

     

    import os.path
    import sys
    from docx import Document
    from docx.enum.text import WD_COLOR_INDEX
    from nltk.tokenize import sent_tokenize
    
    filename = sys.argv[1]
    keywords = sys.argv[2]
    
    search_words = keywords.splitlines()
    matches = []
    sentences = sent_tokenize(text)
    for word in search_words:
       for sentence in sentences:
           if word in sentence:
               matches.append(sentence)
    
    doc = Document(filename)
    
    for para in doc.paragraphs:
        for items in matches:
            start = para.text.find(items)
            if start > -1:
                pre = para.text[:start]
                post= para.text[start+len(items):]
                para.text = pre
                para.add_run(items)
                para.runs[1].font.highlight_color = WD_COLOR_INDEX.YELLOW
                para.add_run(post)
    
    # Save the output in new doc file at selected file location
    root, extension = os.path.splitext(filename)
    output_filename = root + "_KeySent_Highlights_C1" + extension
    doc.save(output_filename)
    sys.stdout.write(output_filename) # e.g. to reveal the file with Alfred

     

     

    @zeitlings thanks for your help.  

     

    I'd start with passing (a) the text file location $loc and (b) the keywords, i.e. the query as $1 for zsh argv

    -- how to do this exactly? Is it possible to post a seperate workflow for it. 

     

    image.thumb.png.b4a181ec3c76f15fe405bf5f841e8c4e.png

     

    I have tried but no clear how I can pass $loc and keywords from earlier workflow into my Python code. I get two errors:

     

    1. line 8, in <module>
        keywords = sys.argv[2]
    IndexError: list index out of range

     

    2. Upon hardcoding keywords for testing, I get the error

    I get line 12, in <module>
        sentences = sent_tokenize(text)
    NameError: name 'text' is not defined 

     

    I have only basic understanding of Python so trying to learn and make this work. Thanks in advance for your help.

     

     

  17. One of my favorite work is this Video conference. This works good on macOS Ventura but running into calendar access issue on macOS Sonoma. @vitor @deanishe and others -- request for review and resolution of this. 

     

    19:21:07 workflow.py:2080 ERROR    No Access to Calendars
    Traceback (most recent call last):
      File "/Alfred.alfredpreferences/workflows/user.workflow.F2AE98BD-B8F2-45B9-AA0E-FFBC6BEBB921/workflow/workflow.py", line 2073, in run
        func(self)
      File "./video-conferences.py", line 240, in main
        raise RuntimeError(data['error'])
    RuntimeError: No Access to Calendars
    19:21:07 workflow.py:2103 DEBUG    ---------- finished in 0.014s ----------
    [19:21:07.683] Video Conferences[Script Filter] {
      "items": [
        {
          "valid": false,
          "subtitle": "No Access to Calendars",
          "icon": {
            "path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
          },
          "title": "Error in workflow 'Video Conferences'"
        }
      ]
    }

  18. @zeitlings request to consider and add an option to extract key sentences (sentences where key phrases are located). It will be great if the docx file key sentences are not only extracted but also highlighted in yellow i.e extract and highlight key sentences option. 

     

    See the code below for sample code in Python. You can add such an option or guide how to incorporate this. 

     

    # Code to highlight keysentences using keyphrases extracted from nlp
    # import required library
    # install textract, rake libraries
    import nltk
    import textract
    from rake_nltk import Rake
    from tkinter import filedialog as fd
    from docx import Document
    from docx.enum.text import WD_COLOR_INDEX
    import tkinter as tk
    import os.path
    
    #nltk.download('stopwords')
    #nltk.download('punkt')
    
    filename = fd.askopenfilename()
    text = textract.process(filename).decode("utf-8")
    rake_nltk_var = Rake(min_length=2, max_length=4, include_repeated_phrases=False, stopwords={'yet', 'would', 'words', 'wise', 'whether', 'wherein', 'went', 'you', 'what', 'usage', 'ultimately', 'to', 'there', 'then', 'that', 'still', 'site', 'when', 'we', 'wants', 'vertical', 'vary', 'try', 'through', 'this', 'so', 'something', 'see', 'shift', 'will', 'said', 'require', 'say', 'or', 'now', 'no', 'much', 'move', 'me', 'part', 'post', 'require', 'related', 's', 'value', 're', 'of', 'it', 'is', 'instead', 'initially', 'let', 'in', 'if', 'i', 'only', 'pick', 'yours', 'within', 'which', 'used', 'use', 'tried', 'those', 'the', 'taken', 'take', 'shows', 'however', 'similar', 'types', 'how', 'work', 'with', 'where', 'way', 'wanted', 'uses', 'us', 'towards', 'typical', 'show', 'same', 'requires', 'remember', 'referred', 'read', 'question', 'volume', 'volumes', 'one', 'two', 'thing', 'things', 'some', 'overview', 'over', 'other', 'various', 'them', 'on', 'off', 'of'}) # min_length and max_length to control words size in phrases and include_repeated_phrases to keep or remove repeated phrases based on true and false
    
    rake_nltk_var.extract_keywords_from_text(text)
    
    keyphrases_extracted = rake_nltk_var.get_ranked_phrases()[:50]  # to increase or decrease the no. of key_phrases to be selected, change value in [ ]
    print("Key_Phrases: ")
    print(keyphrases_extracted)
    print("\n")
    print("No. of Keyphrases extracted are:", str(len(keyphrases_extracted)))
    
    from nltk.tokenize import sent_tokenize
    
    search_words = keyphrases_extracted
    matches = []
    sentances = sent_tokenize(text)
    for word in search_words:
       for sentance in sentances:
           if word in sentance:
               matches.append(sentance)
    print("Extracted key sentences: ")
    print(matches)
    print("\n")
    print("No. of Key sentences extracted are: ", str(len(matches)))
    
    doc = Document(filename)
    
    for para in doc.paragraphs:
        for items in matches:
            start = para.text.find(items)
            if start > -1:
                pre = para.text[:start]
                post= para.text[start+len(items):]
                para.text = pre
                para.add_run(items)
                para.runs[1].font.highlight_color = WD_COLOR_INDEX.YELLOW
                para.add_run(post)
    
        # Save the output in new doc file at selected file location
        root, extension = os.path.splitext(filename)
        output_filename = root + "_KeySent_Highlights_C1" + extension
        doc.save(output_filename)
×
×
  • Create New...