OS Xの「サービス」を使用して、ファイルの連番チェック。
【作成方法】
アプリケーション > Automator > サービスを選択。
ライブラリ > AppleScriptを実行をダブルクリック。
画像のように、AppleScriptコードを入力して、
「連番チェック」などの適当な名前で保存。
▼AppleScriptコード
拡張子の自動取得以外は、
AS Hole(AppleScriptの穴) By Piyomaru Softwareさんの
コードをほぼそのまま使用させていただいてます。
ありがとうございます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
on run {input, parameters} try script spd property aList : {} property nameList : {} property aSel : {} property dameList : {} end script --変数の初期化 set aList of spd to {} set nameList of spd to {} set aSel of spd to {} set dameList of spd to {} try tell application "Finder" set aSel of spd to input as alias list end tell on error return end try set aLen to length of aSel of spd --選択中ファイルの親フォルダを取得する set targFile to (first item of aSel of spd) as alias set EXT to name extension of (info for targFile) tell application "Finder" set ParentFol to folder of targFile set ParentFol to ParentFol as alias end tell set parentalFolStr to ParentFol as string set parentalFolStr to parentalFolStr as Unicode text --選択中のファイルの連番最小値、最大値を取得する repeat with i in aSel of spd set j to contents of i set jj to j as alias tell application "Finder" set aName to name of jj end tell set the end of nameList of spd to (text 1 thru 4 of aName) set the end of aList of spd to jj end repeat set aMin to minimumFromList(nameList of spd) of me set aMax to maximumFromList(nameList of spd) of me repeat with i from aMin to aMax by 1 set tmpPath to parentalFolStr & retZeroPaddingText(i, 4) of me & "." & EXT tell application "Finder" set exRes to exists of file tmpPath end tell if exRes = false then set the end of dameList of spd to i end if end repeat dameList of spd set newdameList to {} if (dameList of spd) = {} then activate display dialog "連番抜けはありませんでした。" else repeat with damefile in (dameList of spd) set the end of newdameList to (damefile as Unicode text) & "、" end repeat activate display dialog (newdameList) as Unicode text set the clipboard to (newdameList) as Unicode text end if on error errMsg activate display dialog errMsg end try end run --最大値を取得する on maximumFromList(nList) script o property nl : nList end script set max to item 1 of o's nl repeat with i from 2 to (count nList) set n to item i of o's nl if n > max then set max to n end repeat return max end maximumFromList --最小値を取得する on minimumFromList(nList) script o property nl : nList end script set min to item 1 of o's nl repeat with i from 2 to (count nList) set n to item i of o's nl if n < min then set min to n end repeat return min end minimumFromList --数値にゼロパディングしたテキストを返す on retZeroPaddingText(aNum, aLen) set tText to ("0000000000" & aNum as text) set tCount to length of tText set resText to text (tCount - aLen + 1) thru tCount of tText return resText end retZeroPaddingText |
【使い方】
チェックしたいファイルを選択して、右クリック。
作成したサービスを選択すると、
結果がダイアログ表示されます。
参考情報
AS Hole(AppleScriptの穴) By Piyomaru Software