on run {input, parameters}
set copyList to {}
tell application "Finder"
activate
set result1 to display dialog "拡張子を入力してください。" default answer "pdf"
set myExt to text returned of result1
try
repeat with ifol in input
set aList to every file of ifol as alias list
repeat with ifile in aList
if (name extension of (info for ifile)) = myExt then
set the end of copyList to ifile
end if
end repeat
end repeat
end try
if (count copyList) > 0 then
set i1 to item 1 of copyList
set oya to parent of parent of i1
try
set makeFol to ((oya as string) & " " & myExt & "収集")
if exists folder makeFol then
set FolNum to 1
repeat until not (exists folder (makeFol & FolNum))
set FolNum to FolNum + 1
end repeat
set copyFol to make new folder at oya with properties {name:" " & myExt & "収集" & FolNum}
else
set copyFol to make new folder at oya with properties {name:" " & myExt & "収集"}
end if
activate
reveal copyFol
end try
set folCount to (count input)
set PDFCount to (count copyList)
try
duplicate copyList to copyFol --ファイル名が重複している場合の処理はしていません。
end try
BeepVolume2() of me --終了時に音を鳴らす。
display alert myExt & "ファイルの収集は終了しました。" & return & return & "フォルダー数:" & folCount & return & myExt & "ファイル数:" & PDFCount
else
BeepVolume2() of me --終了時に音を鳴らす。
display alert myExt & "ファイルは入っていませんでした。"
end if
end tell
return input
end run
on BeepVolume2()
set getvolume to get volume settings
set outVol to output volume of getvolume
set myVol to outVol / (100 / 7)
set volume 1 --beep音量 数値:0-7まで
beep 1
delay 0.3
beep 1
set volume myVol
--say "終了しました" using "Kyoko"
end BeepVolume2