Re: Searching in nested folders
Re: Searching in nested folders
- Subject: Re: Searching in nested folders
- From: Bis <email@hidden>
- Date: Fri, 7 May 2004 15:32:00 +0100
Michelle
Thanks for extending the hand of solidarity across the vibrantly
cooperative community of applescript actualisers (my preferred term
for breaking down the division of labour between users and
developers) !
Initially I was having problems because having defined the
destination folder with a "choose folder" at the beginning this
reference was not being carried over to the copy_files handler. so I
added the destination folder as an extra argument to both the
process_folders and copy_files handlers (see below) and that seems to
have done the trick!
Also initially I had problems with the line
set these_files to (every file of alias this_folder whose kind is not
"alias" and file type is "XDOC")
but once I changed "alias this_folder" to "this_folder" it was fine
(although I am still not sure why!).
I have hardly ever used handlers before so it has been a real
education seeing how arguments are passed between handlers and (this
is the algorithm I had no idea about) how to call a handler
(process_folders) within the same handler, as well as a happy
resolution to a thorny problem.
thank you!
mount volume "afp://bisd:email@hidden/DW SubsDesk"
set the source_folder to "DW SubsDesk:* FINAL PAGES FOR MAD"
set destination_folder to "Atomik HD:Atomik 3.1:Atomik stuff:Atomik
Inbox:DW:server files"
tell application "Finder"
set the File_list to every file of alias the source_folder
whose kind is not "alias" and file type is "XDOC"
set the Folder_list to every folder of alias the source_folder
my copy_files(File_list, destination_folder)
my process_folders(Folder_list, destination_folder)
end tell
to copy_files(the_files, destination_folder)
tell application "Finder"
activate
repeat with i from 1 to the count of the_files
select item i of the_files
with timeout of 300 seconds
duplicate selection to alias destination_folder
end timeout
--end if
end repeat
end tell
end copy_files
to process_folders(the_folders, destination_folder)
tell application "Finder"
repeat with this_folder in the_folders
set these_files to (every file of this_folder
whose kind is not "alias" and file type is "XDOC")
my copy_files(these_files, destination_folder)
set these_folders to the folders of this_folder
my process_folders(these_folders, destination_folder)
end repeat
end tell
end process_folders
>
On May 6, 2004, at 10:28 AM, Bis wrote:
>
>
>What I can't work out is a general algorithm which says:
>
>
>
>1) get a list of all the items in the source folder
>
>2) if any of the items is a quark file copy it to the destination folder
>
>3) if any of the items is a folder get a list of its items
>
>4) if any of these items is a quark file copy it to the destination folder
>
>
set the source_folder to choose folder
>
tell application "Finder"
>
set the File_list to the files of the source_folder
>
set the Folder_list to the folders of the source_folder
>
my copy_files(File_list)
>
my process_folders(Folder_list)
>
end tell
>
>
to copy_files(the_files)
>
--code to copy files goes here
>
end copy_files
>
>
to process_folders(the_folders)
>
tell application "Finder"
>
repeat with this_folder in the_folders
>
set these_files to the files of this_folder
>
my copy_files(these_files)
>
set these_folders to the folders of this_folder
>
my process_folders(these_folders)
>
end repeat
>
end tell
>
end process_folders
>
>
--
>
You can not change the world without perforce changing yourself.
--
_______________________________________________
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.