I try to create a shortcut for macOS Monterey to export data from Tim (a time tracker) and save that data to a file.
I am able to do the first step (export data), but I have no idea how to do the second step (put the text in a file).
One way could be to use a shell script to export the data:
But this gives me an almost empty file:
$ cat tim.txt
Save text to file%
There must be a [better] way to save the data to a text file.
When I try to debug the first step, I get the correct output:
How can I save the text to a file (overwrite the file or create the file if it does not exist.)
CodePudding user response:
After some digging I've found that it is more straightforward than I thought.
There seems to be a bug (or a IMO bad behaviour) in the shortcuts app, the suffix of the file is always .txt
, but I prefer .json
, so I need a third step to rename the file.
The problem I had was to change the directory to the desired output and use a relative filename from there.