Applescript 文件命名
代码片段:
tell application "Finder" to set new_item to ¬
(container of this_item as string) & (name of this_item) & "s"
save this_image in new_item as typ
它将文件另存为 filenames.pngs 我希望它另存为 filenames.png。有什么想法如何解决这个问题吗?
Code snippet:
tell application "Finder" to set new_item to ¬
(container of this_item as string) & (name of this_item) & "s"
save this_image in new_item as typ
Its saving the file as filename.pngs I want it to save as filenames.png. Any ideas how to fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将其保存为应用程序,然后您可以将内容放在上面,它会复制它们并在名称中添加 s。或者您可以双击它,它会要求您选择要复制的文件。 注意:如果您想更改添加到名称中的文本(即“s”),请更改属性appendText。
请注意处理程序 getName_andExtension(f)。这就是我用来从文件中获取名称和扩展名的方法。我用它来计算添加 s 时的新路径。
我希望这有帮助!
Save this as an application, then you can drop things on it and it will copy them adding an s to the name. Or you can double-click it and it will ask you to choose a file to copy. NOTE: change the property appendText if you want to change the text (i.e. "s") that's added to the name.
Notice the handler getName_andExtension(f). That's what I use to get the name and extension from a file. I use that to calculate the new path when adding the s.
I hope that helps!
name of this_item
给出 Finder 项目的全名,包括文件扩展名。你需要把它分开。不幸的是,这并不那么容易。您可以执行以下操作:这只是为 Finder 选择中的第一个项目构建修改后的名称,而不对其进行任何操作。
name of this_item
gives the full name of the Finder item, including the file extension. You need to split it up. Unfortunately, this isn't as easy as it could be. You could do something like:That just builds the modified name for the first item in the Finder selection, without doing anything with it.