처음으로 응용하여 폴더 이름을 기준으로 동영상에 대한 IMDB 링크가 포함 된 .nfo 파일을 만드는 스크립트를 작성했습니다.폴더에 AppleScript로 특정 유형의 파일이 포함되어 있는지 확인하려면 어떻게합니까?
현재 스크립트는 모든 영화가 들어있는 폴더를 사용자에게 묻기 위해 설정되었으며 모든 하위 폴더가 처리 될 때까지 해당 폴더를 반복합니다.
구조는 다음
- 영화
- 영화 1
- 비디오 파일
- 영화 영화 2
- 비디오
1.nfo 파일
- 영화 ... 3
- 비디오 파일
- 영화
3.nfo 등 영화
- 영화 1
도움이 필요합니다. nfo 파일이 이미 존재하는지 확인하기 위해 if-then-else 문을 실행하고 카운터가 다음 폴더로 넘어가거나 아니면 현재 스크립트 코드를 실행하도록 카운터를 늘리십시오. 그냥 신경과하지 않는 것
if (theFiles contains files whose name extension is nfo) then
i = i + 1
else
-- My Code
end if
처럼
내가 시도 물건은 모든 폴더 다시 새 것으로 현재 NFO를 교체 처리합니다.
현재 애플 스크립트는 :
property imdburl : ""
property newurl : ""
property FolderPath1 : ""
property FolderPath : ""
property Foldername : ""
tell application "Finder"
activate
set theFolder to choose folder with prompt "Select the Movie Folder."
set theList to every folder of theFolder
repeat with i from 1 to count the theList
set thisItem to item i of theList as alias
set currentName to name of thisItem
--set currentfolder to get the POSIX path of thisItem
set theFiles to every file of folder thisItem as alias list
if (theFiles contains files whose name extension is nfo) then
i = i + 1
else
tell application "Finder"
set FolderPath1 to thisItem -- sets file path to folder you select
set ParentFolder to container of FolderPath1 -- sets the parent folder of the folder you select
set Foldername to name of folder FolderPath1 -- sets the folder name as text
set FolderPath to get the POSIX path of FolderPath1
set newurl to "http://google.com/search?q=" & Foldername & "+imdb&btnI=I%27m+Feeling+Lucky"
--set the clipboard to newurl -- sets foldername to the clipboard
end tell
tell application "Safari"
open location newurl
activate
delay 3
set imdburl to URL of current tab of window 1
set the clipboard to FolderPath
close window 1
end tell
tell application "TextEdit"
activate
make new document
set text of document 1 to imdburl
set Foldername to text 1 thru -(7 + 1) of Foldername
save document 1 in FolderPath & "/" & Foldername
close document 1
end tell
tell application "Finder" to set name extension of (files of FolderPath1 whose name extension is "rtf") to "nfo"
end if
end repeat
end tell
은을 얻기 위해 포인트 떨어져 나뭇 가지로 사용했다 다음 \t \t \t (currentnfo & ".NFO")는 aList (에있는) 경우 I = I + 1 다른 사람이 접근과 같은 숨겨진 찾기 항목 작동하지 않습니다 – user2296273
주 \t \t 예 '.git' 폴더를 사용하지 않도록주의하십시오. – ssc