Applescriptで認識されていないファイル拡張機能を取得します
-
25-10-2019 - |
質問
私は、文字列からファイル拡張機能を返す方法を疑問に思っていました。の「拡張機能を挙げて...」という詳細を試しました。 これ 質問ですが、それは認識された拡張機能でのみ機能しているようです。アイデアは、拡張機能「.meta」を使用してファイルを独自のコレクションに並べ替えることです。
私が今どのように見えるか
tell application "Finder'
set everyName to name of every item in entire contents of this_folder
end tell
set metaFiles to {}
repeat with n from 1 to count of everyName
set currentName to item n of everyName
set currentExt to last word of currentName --this assignment fails
if currentExt is "meta" then
set end of metaFiles to currentExt
end if
end repeat
私はapplescriptの真新しいので、すべての助け/方向に感謝しています。ありがとう!
編集:ハッキーなソリューション
説明した分割関数を使用してこれを解決しました ここ すべての期間後にファイル名を分割する。私は最後の文字列をつかみ、ピリオド文字がなかった場合に最初の文字列と同じではないことを確認し、対応するファイル名を保存しました。
解決
名前には、ファインダーがそれを認識するかどうかにかかわらず、ファイル拡張子が含まれます。だからこのような名前を並べ替えるだけです...
tell application "Finder"
set metaFiles to (every item in entire contents of this_folder whose name ends with "meta") as alias list
end tell
他のヒント
名前の拡張機能が取得されていない場合は、実際に1つあり、名前の最後を見ていないことを確認してください。ファイルを移動する場合は、名前だけでなくパスを取得する必要もあります。拡張機能のリストを作成することもあなたが目指しているとは思いません。いくつかの異なる文字が単語の境界に使用されますが、期間はそれらの1つではありません。
ファンドアイテムをファインダーに尋ねてみませんか?
tell application "Finder"
set metaFiles to (every item in entire contents of this_folder whose name extension is "meta") as alias list
end tell
所属していません StackOverflow