2017-03-07 2 views
0

저는 완전히 새로운 내용의 applescript입니다. 그러니 ..폴더 안의 특정 파일을 삭제하고 싶습니다. 예를 들어 :AppleScript로 파일명을 지우고 그 이름에 "_s"을 포함하지 않습니다.

  • C9361WL_1.jpg
  • C9361WL_1.jpg
  • C9361WL_2.jpg
  • C9361WL_3.jpg
  • C9361WL_4.jpg
  • C9361WL_1_s :

    나는이 파일이 있습니다. jpg

  • C9361WL_2_s.jpg
  • (210)
  • C9361WL_3_s.jpg
  • C9361WL_4_s.jpg는

나는 이름 파일 내의 "_s"를 포함하지 않는 파일을 삭제합니다.

도움을 주셔서 감사합니다.

여전히
on run {input, parameters} 
    repeat with this_file in input 

     if this_file does not contain "_s" then 
      delete this_file 
     end if 
    end repeat 
    return input 
end run 

이 스크립트를 사용하지 운, 나는 이미

on run {input, parameters} 
    repeat with this_file in input 
     set thePath to POSIX file of this_file as alias 
     set delFiles to (every file of thePath whose name does not contain "_s") 
     tell application "Finder" 
      move files of delFiles to "/Users/dyohanan/Desktop/" 
     end tell 
    end repeat 
    return input 
end run 

답변

1

거의 일부 변경을 할 수 있지만을 수행 할 Finder을 알려줄 필요가 :

내가 자동화에 쓴 코드는 삭제 작업을 수행하고 파일의 이름을 확인하려고합니다.

on run {input, parameters} 
    repeat with this_file in input 
     tell application "Finder" 
      if name of this_file does not contain "_s" then 
       delete this_file 
      end if 
     end tell 
    end repeat 
    return input 
end run 
+0

안녕하세요. 귀하의 도움에 감사드립니다. 나는 당신이 나에게 말한 것을했는데 이제는 오류 메시지가 나타납니다 : 구문 오류 : "항목 1의 이름을 유형 참조로 만들 수 없습니다" – Dan

+0

스크립트는 '입력'이 별칭 지정자 목록이라고 가정합니다. – vadian

+0

당신 말이 맞았습니다. 목록 대신 하나의 항목으로 테스트했을 때 오류가 발생했습니다. 하지만 지금은 오류 메시지가 나타나지 않지만 스크립트는 파일을 삭제하지 않습니다. – Dan