使用 Applescript 创建新文件并替换旧文件
Make new file and replace old one using Applescript
所以我有一个脚本可以在我的文档文件夹中创建一个具有特定名称的文件。我想稍后 运行 代码不止一次,所以我需要替换旧文件。我试图在属性中添加一个 replace:true 但它认为 replace 是一个变量。
tell application "Finder" to make file at (path to home folder) ¬
with properties {name:"textfile.txt",replace:true}
解决方法是(尝试)明确删除文件
set fileName to "textfile.txt"
tell application "Finder"
try
delete file fileName of home
end try
make file at home with properties {name:fileName}
end tell
所以我有一个脚本可以在我的文档文件夹中创建一个具有特定名称的文件。我想稍后 运行 代码不止一次,所以我需要替换旧文件。我试图在属性中添加一个 replace:true 但它认为 replace 是一个变量。
tell application "Finder" to make file at (path to home folder) ¬
with properties {name:"textfile.txt",replace:true}
解决方法是(尝试)明确删除文件
set fileName to "textfile.txt"
tell application "Finder"
try
delete file fileName of home
end try
make file at home with properties {name:fileName}
end tell