在Apple脚本中,您可以使用以下代码来移动特定类型的文件:
-- 设置源文件夹路径
set sourceFolder to POSIX file "/path/to/source/folder" as alias
-- 设置目标文件夹路径
set destinationFolder to POSIX file "/path/to/destination/folder" as alias
-- 获取源文件夹中的所有文件
tell application "Finder"
set fileList to every file of entire contents of sourceFolder
end tell
-- 循环遍历文件列表
repeat with fileRef in fileList
-- 检查文件类型
if (name extension of fileRef) is in {"txt", "doc", "pdf"} then
-- 移动文件到目标文件夹
tell application "Finder"
move fileRef to destinationFolder with replacing
end tell
end if
end repeat
请确保将/path/to/source/folder
和/path/to/destination/folder
替换为实际的源文件夹和目标文件夹路径。上述代码将移动扩展名为txt、doc和pdf的文件到目标文件夹中。如果您需要移动其他类型的文件,请将{"txt", "doc", "pdf"}
更改为所需的文件扩展名列表。