tags:

views:

39

answers:

1

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
+1  A: 

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
regulus6633
I have tried that just now and it still does not work.Here is the code********************on adding folder items to thisFolder after receiving thisItem try 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 -- Dialog box to show information set the alert_message to (the folderCount as text) as Unicode text display dialog the alert_message end tryend adding folder items to*************I now get no dialog box so dont know if it is working?
Sam
You do realize that "after receiving thisItem"... thisItem is a list. You get a list of files even if there was only 1. As such you need to get "item 1 of thisItem". Actually you should rename thisItem to theItems... and then set thisItem to item 1 of theItems... and continue with the script as I've shown.
regulus6633
FYI: if you go here and scroll down to the "adding folder items to" section it shows that you get a list... http://developer.apple.com/mac/library/documentation/applescript/conceptual/applescriptlangguide/reference/ASLR_folder_actions.html
regulus6633