Delete PDF files only from folder using Applescript on MAC

假如想象 提交于 2019-12-24 11:34:09

问题


I need to delete the PDF files only from a folder on a network drive. There are other file types in the folder I can not touch. I am assuming I have to choose or identify the PF files first and then move them to the trash or delete them.

What I have so far:

tell application "Finder"
    set theFolder to "Macintosh HD:Users:Kathlene:Desktop:ABC123_JOB"
    set destFolder to "Server/JOBS/TRANSFER_TRASH/"
    set thePDFs to every file of theFolder whose name extension is "pdf"
    move thePDFs to destFolder
end tell

What I get for an error:

error "Can’t get every file of \"Macintosh HD:Users:Kathlene:Desktop:ABC123_JOB:\"." number -1728 from every file of "Macintosh HD:Users:Kathlene:Desktop:ABC123_JOB"


回答1:


Try:

tell application "Finder" to delete (files of folder "Macintosh HD:Users:Kathlene:Desktop:ABC123_JOB" whose name extension is "pdf")


来源:https://stackoverflow.com/questions/15281869/delete-pdf-files-only-from-folder-using-applescript-on-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!