rounak Posted September 2, 2016 Share Posted September 2, 2016 Could someone please post an example of this? Most of the results I found in google involve Script Filters using python scripts which I know nothing about. I know applescript. Link to comment
deanishe Posted September 2, 2016 Share Posted September 2, 2016 (edited) Script Filters are how you show your own results in Alfred. You write a script that outputs JSON in the format required by Alfred (Alfred Preferences > Workflows > + > Getting Started > Script Filter Output). Alfred calls your script and shows you its results. In theory, you can write the script in any language, but it's a lot harder if the language doesn't support JSON, and AppleScript doesn't. That's why you can't find any AppleScript examples on Google: almost nobody uses AppleScript for Script Filters because it's not a good tool for the job. I haven't got a clue where you could find an AppleScript example, and I don't know how to write one that isn't seriously broken. Edited September 2, 2016 by deanishe Link to comment
rounak Posted September 9, 2016 Author Share Posted September 9, 2016 (edited) I think you referenced me this page in some other thread: https://github.com/mgax/applescript-json Future readers of this thread must have an answer instead of returning back hopeless. Hence, this post. I was able to do this: tell application "Finder" set json_path to file "json.scpt" of folder of (path to me) end tell set json to load script (json_path as alias) set theCSVfile to (POSIX path of (path to home folder)) & "/Downloads/sample.csv" --remove all quotes from the csv file. set theCSVfile to do shell script "sed 's/\"//g' " & theCSVfile set allParas to every paragraph of theCSVfile set theResult to {} repeat with aPara in allParas set aPara to aPara as text set my_dict_2 to json's createDictWith({{"title", aPara}, {"arg", aPara}}) set end of theResult to json's encode(my_dict_2) end repeat --return theResult do shell script "echo " & quoted form of (theResult as text) & " > ~/Desktop/deleteme__.txt" I put / \ and ' in some strings in my csv file to check if gives the output correctly. Here is the file that needs to be in the same folder as your applescript. Or just paste the code in your applescript. (Posting something on GitHub really complicates simple matters for those like me who don't use it): https://www.dropbox.com/s/yhhniidejzxovus/json.scpt?dl=0 This is my sample csv. Actually, I had just one column in my original csv. I have not modified the above pasted applescript code to demonstrate working with two columns. https://www.dropbox.com/s/9jp7ufzehckalgt/sample.csv?dl=0 Result: https://www.dropbox.com/s/1an5d361eldxxrr/deleteme__.txt?dl=0 PS: code above looks better, when code tags are not used. Edited September 9, 2016 by rounak Link to comment
addEdgeBookmarkSearch Posted January 21 Share Posted January 21 If you're finding how to get bash command output in a workflow to show it with notification/LargeType, you can try this: ``` output=$(yourcommand 2>&1) echo -n "$output" ``` put this on a [Run Script] object followed by a notification. Link to comment
addEdgeBookmarkSearch Posted January 21 Share Posted January 21 15 hours ago, addEdgeBookmarkSearch said: If you're finding how to get bash command output in a workflow to show it with notification/LargeType, you can try this: ``` output=$(yourcommand 2>&1) echo -n "$output" ``` put this on a [Run Script] object followed by a notification. My bad. Just put the command in the textbox of [Run Script] object, make sure you delete the "echo -n $query". yourcommand Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now