Applescript 无法计算子文件夹中的文件数

发布于 2024-09-17 08:45:08 字数 970 浏览 4 评论 0原文

我似乎根本无法让它发挥作用。如果有人能提供帮助或照亮它,那就太好了?

谢谢

on adding folder items to thisFolder after receiving thisItem

 try

  -- This gives you the name of the route folder, and the name of the added folder
  set folderName to name of (info for thisFolder)
  set itemName to name of (info for thisItem)

      -- I am trying to find out how many items the new folder that has been added to the route folder has but none of the variables below work
  -- Example: Route Folder > New Folder > # of files in new folder?
  set the numberOfFiles to the number of items in itemName
  set fileCount to (count (info for thisItem))
  set the item_count to the number of items in thisItem

  -- Dialog box to show information
  set the alert_message to (the folderName as text) & return & (the itemName as text) & return & (the item_count as text) as Unicode text
  display dialog the alert_message

 end try
end adding folder items to

I cant seem to get this to work at all. Would be great if anyone could help or shine some light on it?

Thanks

on adding folder items to thisFolder after receiving thisItem

 try

  -- This gives you the name of the route folder, and the name of the added folder
  set folderName to name of (info for thisFolder)
  set itemName to name of (info for thisItem)

      -- I am trying to find out how many items the new folder that has been added to the route folder has but none of the variables below work
  -- Example: Route Folder > New Folder > # of files in new folder?
  set the numberOfFiles to the number of items in itemName
  set fileCount to (count (info for thisItem))
  set the item_count to the number of items in thisItem

  -- Dialog box to show information
  set the alert_message to (the folderName as text) & return & (the itemName as text) & return & (the item_count as text) as Unicode text
  display dialog the alert_message

 end try
end adding folder items to

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

〗斷ホ乔殘χμё〖 2024-09-24 08:45:08

如果 thisItem 是您添加的文件夹,请执行以下操作...

tell application "Finder"
    if kind of thisItem is "Folder" then
        set itemsInTheFolder to items of thisItem
        set folderCount to count of itemsInTheFolder
    end if
end tell

if thisItem is a folder that you added do this...

tell application "Finder"
    if kind of thisItem is "Folder" then
        set itemsInTheFolder to items of thisItem
        set folderCount to count of itemsInTheFolder
    end if
end tell
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文