How can I read the filename from a script? #1803
-
I currently have a script that stuffs its input into HTML and sends that to the browser using data:text/html. This works OK, but I have some markdown files under a local web server's docroot that I'd like to serve directly. So I'm trying to get the path of the specific file when running a script. I've looked in both the ENV and $@ but neither contains the file path. Is there another way to get this data? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Beta Was this translation helpful? Give feedback.
-
So it does! I hoped that would be the case but, for some reason, I only tested with $0 and didn't check $1. |
Beta Was this translation helpful? Give feedback.
CotEditor passes the document file path as an argument when the CotEditor script is an UNIX script (= not an AppleScript), and the document is already saved somewhere so that is has a file path.
In case, I’ve also quickly tested it in the latest environment (macOS 15.3 and CotEditor 5.0.8) and confirmed that it still works.
Example in Python