I am using
Write Text to File action in a macro, to replace a file with new text.
The issue is that I use this macro a lot and really dislike how every time I do it, it will put the previous file that existed into trash. Is it possible to somehow overwrite this behavior and cleanly replace the file with new contents?
How my macro looks:
Just add a
Delete file action anywhere before the
Write file one with that same file path:
If you really want to overwrite the file, you can do something like this.
Write Clipboard to File -- AppleScript Version.kmmacros (7.3 KB)
The macro above requires that all the directories in the path to the target file already exist.
This one will create them if necessary:
Write UTF-8 Text to File using AppleScriptObjC v1.10
Both are fully UTF-8 compatible.