Trying to write code that recursively 'drills down' into nested folders, then applies a script to the contents of the bottom folders files.
Here is the code so far - I have a structure with the following folders:
temp>2006>Jan>Jan1>many files
..................................Jan3>many files
..................................Jan 15>many files
..................................file 1
..................................file 2
............................feb>feb9>many files
so - five levels of nesting, with some files at the fourth level in Jan. Here is the drill_down code:
on drill_down(fpath)
tell application "Finder"
set item_list to list folder fpath without invisibles
set counter to count of item_list
set fpath to fpath as string
repeat with i from 1 to counter
set this_item to item i of the item_list
set this_item to (fpath & this_item) as alias
set this_info to info for this_item
set the container_name to the name of container of this_item
if kind of this_info is "Folder" then
open this_item
my drill_down(this_item)
end if
beep 1
return (container of this_item)
exit repeat
end repeat
end tell
end drill_down
drill_down({alias "Macintosh HD:Usersld_bfindlayesktop:temp:"})
When I run this - it beeps four times, opens the folders 2006, Feb and Feb9 and the result is:
folder "temp" of folder "Desktop" of folder "old_bfindlay" of folder "Users" of startup disk of application "Finder"
So I am misunderstanding what this code is telling applescript to do. What I thought it would do would be to drill down to the Feb9 level, beep once and return the container value 'Feb9' - indicating it was on the first of the files that reside there.
...color me lost.
Here is the code so far - I have a structure with the following folders:
temp>2006>Jan>Jan1>many files
..................................Jan3>many files
..................................Jan 15>many files
..................................file 1
..................................file 2
............................feb>feb9>many files
so - five levels of nesting, with some files at the fourth level in Jan. Here is the drill_down code:
on drill_down(fpath)
tell application "Finder"
set item_list to list folder fpath without invisibles
set counter to count of item_list
set fpath to fpath as string
repeat with i from 1 to counter
set this_item to item i of the item_list
set this_item to (fpath & this_item) as alias
set this_info to info for this_item
set the container_name to the name of container of this_item
if kind of this_info is "Folder" then
open this_item
my drill_down(this_item)
end if
beep 1
return (container of this_item)
exit repeat
end repeat
end tell
end drill_down
drill_down({alias "Macintosh HD:Usersld_bfindlayesktop:temp:"})
When I run this - it beeps four times, opens the folders 2006, Feb and Feb9 and the result is:
folder "temp" of folder "Desktop" of folder "old_bfindlay" of folder "Users" of startup disk of application "Finder"
So I am misunderstanding what this code is telling applescript to do. What I thought it would do would be to drill down to the Feb9 level, beep once and return the container value 'Feb9' - indicating it was on the first of the files that reside there.
...color me lost.