私はこれがシンプルだと感じますが、私は長いことを見落としています。それを自分で試して2時間後に、私はそれ以上のことを検討しながら助けを求めています。AppleScriptで同じ長さではない2つのリストを比較するにはどうすればよいですか?
私は2つのリストを比較しようとしていますが、同じ長さではありません。私がしようとしているのは、フォルダ内の総合計ファイルのリストを取得し、各ファイルをMP4またはMTSのいずれかに移動して、それぞれのリストを取得し、2つの正確な位置を比較して、 MP4の対応がある場合は、新しいリストにMTSファイル名を追加して、後でファインダーで選択します。現実世界で使用できるようになるまで、totalFiles変数のプレースホルダを使用しています。プレースホルダでは、MP4がないため、結果は「6534-Seasons.MTS」になります。代わりに、MTSほど多くないのでMP4リストのそれを検索できないため、クラッシュします。このような状況では、MTSなしのMP4は存在しません。
私はMP4の数がほとんどMTSファイルの数よりも少なくなるため、2つの別々のリストを作成し、それらを少し比較してから私のリピートループが壊れていることを発見しました。ここにあるものは
--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