03)フォルダ選択 choose folder

| コメント(0) | トラックバック(0)

choose folderでフォルダ選択ダイアログを出せます。フォルダはalias型の値で返ってきます。フォルダ内のファイルを全て処理するには下記のようなrepeatを使います。list folder フォルダでフォルダ内のファイルがリスト形式で返ってきますが、それらはファイル名のみです。そのためファイルの位置はフォルダのフルパス+ファイル名で調べます。

set myFol to choose folder with prompt "フォルダを選択"
set myFol to myFol as string--フォルダのフルパス
repeat with myFile in list folder myFol without invisibles--フォルダ内リピート
	set this_item to (myFol & myFile) as alias--フォルダとファイル名を合体
	set Fpath to this_item as string--フルパスを取り出す
	display dialog Fpath
end repeat

下記はフォルダ内のフォルダも含めて繰り返します。

set myFol to choose folder with prompt "フォルダを選択"
my folderLoop(myFol)--オリジナル関数folderLoopを呼び出す

on folderLoop(myFol)
	set myFol to myFol as string
	repeat with myFile in list folder myFol without invisibles
		set this_item to (myFol & myFile) as alias
		set myInfo to info for this_item
		if folder of myInfo is true then
			my folderLoop(this_item)--自分自身を呼び出す
		else
			set Fpath to this_item as string
			display dialog Fpath
		end if
	end repeat
end folderLoop

トラックバック(0)

トラックバックURL: http://www.adg7.com/mt/mt-tb.cgi/33

Comments are nofollow setting

コメントする

エントリー一覧

OpenID対応しています OpenIDについて
Powered by Movable Type 7.902.0
漢字イラストロジック-脳トレ京
FREE ONLINE SUDOKU