on run tell application "Finder" beep display alert "ドロップレット形式です。 ファイルをドラッグ&ドロップしてください。 画像ファイルの縦横サイズを計測して 指定するファイル名と共にリネームします。 オプションで日付を付ける事が出来ます。 " as informational return end tell end run on open DropObj tell application "Finder" activate set the File_count to 0 set the Fcount to "" as Unicode text set the exeName to "" as Unicode text set the aWidth to "" as Unicode text set the aHeight to "" as Unicode text set newexeName to "" as Unicode text set nowTime to my DateAndTIme(current date) set the theName to "" as Unicode text display dialog "ファイル名の頭に来る文字を入力" default answer "" buttons {"Rename", "RenameDATE"} with icon 1 default button 1 if button returned of the result is "RenameDATE" then set MainFileName to text returned of the result as Unicode text set the NameSelect to "2" as Unicode text else if button returned of the result is "Rename" then set MainFileName to text returned of the result as Unicode text set the NameSelect to "1" as Unicode text end if end tell ------------------------------------------------本作業 repeat with ObjFiles in DropObj set afile to ObjFiles --------------------------------------------------ファイルの縦横サイズを取得 tell application "Image Events" launch set this_image to open afile set {aWidth, aHeight} to dimensions of this_image close this_image end tell tell application "Finder" --------------------------------------------------ファイル名を取得 set theName to name of ObjFiles --------------------------------------------------.0を取る set RepName to ".0" as Unicode text set NaHeight to my replace((aHeight as Unicode text), RepName, "") as Unicode text set NaWidth to my replace((aWidth as Unicode text), RepName, "") as Unicode text ------------------------------------------------パスを取得 set theAlias to ObjFiles as alias ------------------------------------------------パスを文字列に変換 set theAliasPath to theAlias as string ------------------------------------------------拡張子を定義 set exeName to name extension of ObjFiles --------------------------------------------------拡張子を小文字に変更文字 --------------------------------------------------macwiki.sourceforge.jpより引用 repeat with aChar in every character of exeName set asNum to ASCII number aChar if (asNum > 64) and (asNum < 91) then set aChar to ASCII character (asNum + 32) -- tr/A-Z/a-z/ -- if (asNum > 96) and (asNum < 123) then set aChar to ASCII character (asNum - 32) -- tr/a-z/A-Z/ set newexeName to newexeName & aChar end repeat --------------------------------------------------連番に1を加算 set File_count to File_count + 1 --------------------------------------------------10以下の数字は0102形式に変換 set Fcount to my zero1(File_count) --------------------------------------------------ファイル名を定義 if NameSelect is "2" then set the new_file_name to the (the NaWidth & "x" & NaHeight & "+" & the MainFileName & "+" & the nowTime & "+" & the Fcount & "." & newexeName) as Unicode text else if NameSelect is "1" then set the new_file_name to the (the NaWidth & "x" & NaHeight & "+" & the MainFileName & "+" & the Fcount & "." & newexeName) as Unicode text end if -------------------------------------------------フルパスからファイル名を抜いてディレクトリ名を作る set DirName to my replace(theAliasPath, theName, "") -------------------------------------------------ファイル名を変更 set name of file theName of folder DirName to new_file_name -------------------------------------------------拡張子の名前をリセット set the exeName to "" -------------------------------------------------拡張子の名前をリセット set newexeName to "" end tell end repeat end open --------------------------------------------------#ここからサブルーチン to DateAndTIme(theDate) set y to (year of theDate) set m to my monthNumStr(month of theDate) set d to day of theDate set hms to time of theDate set hh to h of sec2hms(hms) set mm to m of sec2hms(hms) set ss to s of sec2hms(hms) ----return (y as text) & my zero1(m) & my zero1(d) & "_" & zero1(hh) & zero1(mm) & zero1(ss) return (y as text) & my zero1(m) & my zero1(d) end DateAndTIme --------------------------------------------------#ここからサブルーチン to monthNumStr(theMonth) set monList to {January, February, March, April, May, June, July, August, September, October, November, December} repeat with i from 1 to 12 if item i of monList is theMonth then exit repeat end repeat return i end monthNumStr --------------------------------------------------#ここからサブルーチン to zero1(n) if n < 10 then return "0" & n else return n as text end if end zero1 --------------------------------------------------#ここからサブルーチン to replace(theText, orgStr, newStr) set oldDelim to AppleScript's text item delimiters set AppleScript's text item delimiters to orgStr set tmpList to every text item of theText set AppleScript's text item delimiters to newStr set tmpStr to tmpList as text set AppleScript's text item delimiters to oldDelim return tmpStr end replace --------------------------------------------------#ここからサブルーチン to sec2hms(sec) set ret to {h:0, m:0, s:0} set h of ret to sec div hours set m of ret to (sec - (h of ret) * hours) div minutes set s of ret to sec mod minutes return ret end sec2hms