Finder -> Loop through folders
Finder -> Loop through folders
- Subject: Finder -> Loop through folders
- From: Jon Otaegi <email@hidden>
- Date: Tue, 13 Jul 2004 18:00:03 -0400
Hello listmembers,
I have to create a script that loops through the entire content of a
hard drive to check if there are filenames longer that 31 characters.
I tried with the following script:
set folder_path to choose folder with prompt "Choose a Folder"
loopThroughFolders(folder_path)
on loopThroughFolders(the_path)
tell application "Finder"
-- This checks for filenames > 31 chars inside the given folder
set file_list to list folder (the_path)
repeat with filename in file_list
if length of filename is greater than 31 then
display dialog ((the_path as text) & filename)
end if
end repeat
-- This checks for additional folders within the original folder and
loops through them
if number of folders in the_path > 0 then
repeat with the_subpath in every folder of the_path
loopThroughFolders(the_subpath) of me
end repeat
end if
end tell
end loopThroughFolders
The script fails when checks for additional folders within the original
one. Here is the error:
if number of folders in the_path > 0 then
( Finder got an error: Expected a reference)
I also tried without this line:
set folder_path to choose folder with prompt "Choose a Folder"
loopThroughFolders(folder_path)
on loopThroughFolders(the_path)
tell application "Finder"
-- This checks for filenames > 31 chars inside the given folder
set file_list to list folder (the_path)
repeat with filename in file_list
if length of filename is greater than 31 then
display dialog ((the_path as text) & filename)
end if
end repeat
-- This checks for additional folders within the original folder and
loops through them
repeat with the_subpath in every folder of the_path
loopThroughFolders(the_subpath) of me
end repeat
end tell
end loopThroughFolders
Then, it works OK with the files inside the main folder but fails with
the first subfolder:
set file_list to list folder (the_path)
(Finder got an error: Can't make some data into the expected type)
Any ideas?
Thanks in advance,
Jon
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.