Homeまぐろ>フォルダ内ファイル数カウント&リスト作成

フォルダ内ファイル数カウント&リスト作成

指定されたフォルダ内にあるテキストファイル数をカウントしiniファイルに書き込み、フォルダ内にあるテキストファイル名のリストを別のtxtファイルに保存します。
これを足がかりにした別の大きなマクロをつくるための準備のためにつくりました。
ちなみに、最初の18行ぐらいまでは一太郎のマクロバイザーの例文をぱくってます。

%file = "filelist.txt" Message("設定ファイルを保存するフォルダを選択してください。",0) %str1 = InputDirectory("C:\JUST") if %str1 <> nil %mode = &H0100 !! Exclusive(ファイルが存在する場合はエラー) if ExistFile(%str1&%file) then %shifou = MsgBox(\\ "既に '" & %file & "' は存在しています。" & Char(10) \\ & "既存のファイルを破棄しますか?", \\ {.Button = 5}) if %shifou = 6 then %mode = 0 !! 「はい」が押された場合は、長さを 0 にする CreateFile(%str1&%file, %mode) MsgBox("ファイル '" & %file & "' を作成しました。") end if end if else MsgBox("マクロを中止します。") stop end if Message("ファイルを探すフォルダを選択してください。",0) %str2 = InputDirectory("C:\Windows") if %str2 <> nil %wenjian=GetFileList(%str2, "*.txt", 1, 2, 1) Open(1, %str1&%file) %duoshao=0 foreach %jpeg in %wenjian LinePrint(1,%jpeg) %duoshao=%duoshao+1 next Message("ファイル数は"&%duoshao&"です") Create(2, %str1&"filelist.ini") LinePrint(2,%duoshao) Close(1) Close(2) else MsgBox("マクロを中止します。") end if end

Homeまぐろ>フォルダ内ファイル数カウント&リスト作成