좋아, 이건 단순하다고 느낀다. 그러나 나는 오랜 일들을 간과하고있다. 그리고 스스로 시도하기 위해 2 시간이 지난 후에, 나는 그것을 더 많이 검토하는 동안 도움을 요청하고있다.AppleScript에서 동일한 길이가 아닌 두 목록을 비교하려면 어떻게해야합니까?
나는 applescript에서 2 개의 목록을 비교하려고하는데, 같은 길이는 아니지만 순서는 같습니다. 내가하려는 것은 폴더에있는 모든 전체 파일의 목록을 가져 와서 각 파일을 MP4 또는 MTS로 이동하고 각각의 목록을 가지고 두 개의 정확한 위치를 비교하여 어떤 MTS 파일이 아닌지 확인합니다. MP4를 가지고 있다면, MTS 파일 이름을 새 목록에 추가하여 나중에 Finder에서 선택하십시오. 실제 세계에서 사용할 준비가 될 때까지 totalFiles 변수에 대한 자리 표시자를 사용하고 있습니다. 자리 표시 자에서 결과는 "6534-Seasons.MTS"여야합니다. MP4가 없기 때문입니다. 대신 MTS만큼 많지 않기 때문에 MP4 목록에서 멀리 검색 할 수 없기 때문에 충돌이 발생합니다. 이 상황에서 MTS가없는 MP4는 절대 존재하지 않습니다.
나는 MP4의 수가 대부분 MTS 파일의 수보다 낮기 때문에 두 개의 별도 목록을 작성하고이를 반복적으로 비교하는 것으로 나타났습니다. 여기에 내가 무엇을 가지고
--Look for files that don't have .MP4, find their MTS counterpart.
set totalFiles to {"41 - The words.MTS", "41 - The words.MP4", "445 - Life on the rails.MTS", "445 - Life on the rails.mp4", "6354-Seasons.MTS"} -- List of all files in folder
set clickList to {}
--log totalFiles
--log vidlist
on siftfiles(totalFiles)
--Sift through everything and find mp4s, then add to a list. Do the same for MTS but add separately.
set MTSlist to {}
set MP4list to {}
repeat with vidname in totalFiles
if (vidname contains ".MP4") or (vidname contains ".mp4") then
set end of MP4list to vidname as string
end if
if vidname contains ".MTS" then
set end of MTSlist to vidname as string
end if
end repeat
set returnlist to {MP4list, MTSlist}
return returnlist
end siftfiles
set MP4slist to item 1 of siftfiles(totalFiles)
set MTSlist to item 2 of siftfiles(totalFiles)
--siftfiles(totalFiles)
--MP4slist
--Compare the two lists
set clickList to {}
set i to 1
repeat with thename in MTSlist
set MP4name to characters 1 thru -5 of item i of MP4slist as string
set MTSname to characters 1 thru -5 of item i of MTSlist as string
if MP4name is not MTSname then
set end of clickList to (thename as string)
end if
set i to i + 1
end repeat
clickList
고마워.
나는이 문제에 대한 접근 방식을 몇 번 개선했기 때문에 비교하는 것보다 더 좋은 방법이 있을까요?
dammit @jweaks 1 분 미만으로 나를 이길 수 있습니다! :-) – CRGreen