Skip to content

How can I read the filename from a script? #1803

Closed Answered by 1024jp
bobbykjack asked this question in Q&A
Discussion options

You must be logged in to vote

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

import sys

filepath = sys.argv[1]
print(filepath, file=sys.stderr)

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by 1024jp
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants