0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GoogleのSVGアイコンをFileMakerで使えるようにするAppleScript

Posted at

Google の icon を FileMaker で使うを読んで、いちいちエディタで修正するのもなんだな〜と思ってDropletを作ってみました。
実際の置換部分はsedを使ってます。
`-e指定で検索パターンを並べれば列記できるようですが、エラーが出てしまい、解決できなかったので2回連続で置換することに……

下記コードをスクリプトエディタにコピー&ペースト。アプリケーション形式で保存すればドロップレットができますので、material.ioからダウンロードしたsvgファイルをDrag&Dropすれば、FileMakerで不具合なく扱えるSVGファイルができあがります。

(*
	GoogleのSVGアイコンをFileMakerで使えるようにテキスト置換するスクリプト
	
	2018-12-26
*)


on open (dropList)
	repeat with aFile in dropList
		
		set aExt to name extension of (info for aFile)
		if aExt is "svg" then
			my main(aFile)
		end if
		
	end repeat
end open


on main(aFile)
	set find to {"<path\\ d=\\\"M0.\\{1,\\}none.\\/>", "\"24\""}
	set rep to {"", "\\\"50\\\""}
	
	set src to POSIX path of aFile
	
	my sedRep(src, find's item 1, rep's item 1)
	my sedRep(src, find's item 2, rep's item 2)
	
end main

on sedRep(src, find, rep)
	set shcmd to "sed -i \"\" -e 's/" & find & "/" & rep & "/g' " & (quoted form of src)
	my doshell(shcmd)
end sedRep

on doshell(shcmd)
	do shell script shcmd
end doshell

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?