This is a script that I found on the net and I thought if I add the “on open” command will make it work. It doesn’t seem to generate and error.
Could anyone suggest a code to make it work and why it doesn’t work.
on open target_folder
tell application "Finder"
set files_ to count files of entire contents of target_folder
set folders_ to count folders of entire contents of target_folder
display dialog ("Path: " & POSIX path of target_folder) & return & return & ¬
"Files: " & files_ & return & "Sub-folders: " & folders_ & return & ¬
"Total ItemCount: " & (files_ + folders_) buttons ¬
{"OK"} default button 1 giving up after 5
end tell
end open
Not your fault, the input just needed to be coerced as alias.
on open target_folder
tell application "Finder"
set files_ to count files of entire contents of (target_folder as alias)
set folders_ to count folders of entire contents of (target_folder as alias)
display dialog "Path: " & (POSIX path of target_folder) & "
" & "Files: " & files_ & "
" & "Sub-folders: " & folders_ & "
" & "Total ItemCount: " & (files_ + folders_) buttons {"OK"} default button 1 giving up after 5
end tell
end open
the parameter of the open command is always a list of aliases
on open target_folder
tell application "Finder"
repeat with oneFolder in target_folder
if class of item (oneFolder as text) is folder then -- check the class of the item
set files_ to count files of entire contents of oneFolder
set folders_ to count folders of entire contents of oneFolder
display dialog ("Path: " & POSIX path of oneFolder) & return & return & ¬
"Files: " & files_ & return & "Sub-folders: " & folders_ & return & ¬
"Total ItemCount: " & (files_ + folders_) buttons ¬
{"OK"} default button 1 giving up after 5
end if
end repeat
end tell
end open