[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(DTPtechNote:620) EPSのBounding Box



EPSのBoundingBox値をとります。
このときファイル名をキーにできます。

情報の拡散か。。。(爆)

set my_folder to choose folder

set my_folder to (quoted form of POSIX path of my_folder) as Unicode text
set my_bounds to do shell script ("cd " & my_folder & "; grep  --binary-files=text '^%%BoundingBox' *.eps")
set my_bounds to my as_replace(my_bounds, ":%%BoundingBox:", "") as Unicode text
set my_bounds to my as_split(return, my_bounds)
if my_bounds is not {} then
	set my_bounds_record to {}
	repeat with i in my_bounds
		set tmp_list to my as_split(" ", contents of i)
		set my_bounds_record to my_bounds_record & my list2record({contents of item 1 of tmp_list, contents of items 2 thru -1 of tmp_list})
	end repeat
end if
my_bounds_record
--|ほにゃらら.eps| of my_bounds_record



to as_split(thedelimit, theText)
	set oldDelim to AppleScript's text item delimiters
	set AppleScript's text item delimiters to thedelimit
	set tmpList to every text item of theText
	set AppleScript's text item delimiters to oldDelim
	return tmpList
end as_split

to as_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 as_replace


to list2record(my_list)
	try
		{ヌclass usrfネ:my_list}'s x
	on error msg
		run script text 16 thru -2 of msg
	end try
end list2record