Macos 如何在finder中复制一批文件
我以前从未使用过Apple脚本,我发现自己需要完成一项非常重复的任务。基本上,我需要做的是按照一种模式批量复制和重命名许多文件。最好我需要一个对话框说 “有多少份?” 如果我有这个: 1-1.jpg 1-2.jpg 1-3.jpg (可以突出显示任意数量的文件,而不仅仅是三个) 我主要想做的是突出显示所有三个文件,然后从“服务”菜单调用Applescript,询问我要制作多少个副本,然后重命名它们: 2-1.jpg2-2.jpg2-3.jpg3-1.jpg3-2.jpg3-3.jpg 显然,这取决于我需要多少副本Macos 如何在finder中复制一批文件,macos,file,duplicates,applescript,Macos,File,Duplicates,Applescript,我以前从未使用过Apple脚本,我发现自己需要完成一项非常重复的任务。基本上,我需要做的是按照一种模式批量复制和重命名许多文件。最好我需要一个对话框说 “有多少份?” 如果我有这个: 1-1.jpg 1-2.jpg 1-3.jpg (可以突出显示任意数量的文件,而不仅仅是三个) 我主要想做的是突出显示所有三个文件,然后从“服务”菜单调用Applescript,询问我要制作多少个副本,然后重命名它们: 2-1.jpg2-2.jpg2-3.jpg3-1.jpg3-2.jpg3-3.jpg 显然,这取
对于有Applescript知识的人来说,这可能是一个一分钟的工作,但是,唉,仅仅为了做到这一点,我还需要一些时间来学习 如果突出显示文件,然后按Command+D(Duplicate)键,次数与所需的重复次数相同,则基本上已经可以在不使用任何AppleScript的情况下获得该文件。唯一不同的是,您将获得更清晰的命名副本:
- 1-1.jpg
- 1-1 copy.jpg
- 1-1份副本1.jpg
- 1-1份副本2.jpg
- 等等
这正是人们第一次学习AppleScript时所做的项目。有很多在线学习资源,如和其他。您可以从其他人的Finder脚本开始,它几乎可以满足您的需求,然后调整它以满足您的需求。下面的脚本可以满足您的需求(我认为!) 示例:在文件夹“MyFolder”中仅选择了1个文件“1-SurverName.jpg”,要求有2个重复的文件 “Myfolder”中的结果是“1-supername.jpg”、“2-supername.jpg”、“3-supername.jpg” 当然,如果选择了多个文件,则每个文件在各自的文件夹中都将得到相同的处理
tell application "Finder" to set MyFiles to selection
set NbFiles to count of MyFiles
if NbFiles = 0 then return
set Dupli to 0
set myAnswer to display dialog "There are " & NbFiles & " selected. How many duplicate do you want ?" default answer "1"
try
set Qty to text returned of myAnswer
on error
set Qty to 1
display dialog "Job cancelled. value entered incorrect"
end try
display dialog "Please confirm that you want to duplicate " & Qty & " times the " & NbFiles & " files selected ?"
repeat with F in MyFiles -- duplication for each selected file
set myName to name of F
set myFolder to POSIX path of ((folder of F) as string)
set AppleScript's text item delimiters to {"-"}
set ListName to text items of myName
set myCount to (item 1 of ListName) as integer
repeat with I from 1 to Qty -- for each duplication
set myCount to myCount + 1 -- counter of the begining of the file name
set item 1 of ListName to (myCount as string) --increase the counter for the new name
set newName to ListName as string
try
do shell script "cp " & quoted form of (myFolder & myName) & " " & quoted form of (myFolder & newName)
on error
display dialog "error during copy of " & myName & " into " & newName
end try
end repeat
end repeat
批处理文件标签用于Windows批处理文件。编辑您的问题并删除该标签。嗨,伙计们,所以我正试图从OSX转移到Windows上(不要签名-我听说了!)我正试图找到一种在Windows 10上实现这一结果的方法。我知道这可能超出了这个原始问题的范围,但我真的很难理解Windows脚本是如何工作的:(谢谢大家-这非常有用!我刚刚开始我的Applescript之旅,这对学习也有很大帮助!