Re: Alias List or Repeat in 8.1
Re: Alias List or Repeat in 8.1
- Subject: Re: Alias List or Repeat in 8.1
- From: "Marc K. Myers" <email@hidden>
- Date: Thu, 20 Dec 2001 12:10:56 -0500
- Organization: [very little]
>
Date: Wed, 19 Dec 2001 21:28:04 -0700
>
Subject: Alias List or Repeat in 8.1
>
From: Bryan Kobler <email@hidden>
>
To: "AppleScript List" <email@hidden>
>
>
Hello,
>
>
I am still working on my transfer script. This script looks at a folder
>
and FTPs the contents to another place. What happens is the script
>
below....
>
>
tell application "Finder"
>
set aVar to every item of alias SourceFolder as alias list
>
end tell
>
>
That code will look inside a folder and make an alias list out of all
>
the folders inside, then Fetch can upload them. My problem is using
>
this line on a Mac OS 8.1 system, I am forced to use 8.1 on these
>
machines because certain software requires it. It seems 8.1 doesn't
>
understand "alias list" and using "alias as list" only works if there is
>
one folder inside of "SourceFolder". Does anyone know of a way to
>
modify this?
>
>
I have tried using the approach of looping to take each folder one at a
>
time. This is what I have tested but I am having trouble...
>
>
-- sets path to a folder on the desktop
>
set DeskPath to the path to desktop as string
>
set SourceFolder to (DeskPath & "test:") as string
>
>
-- counts the folders in SourceFolder, it runs the script for each
>
folder inside SourceFolder
>
>
repeat with m from 1 to length of SourceFolder
>
set SubFolder to (SourceFolder & item m of SourceFolder) as text
>
>
tell application "Finder"
>
set aVar to SubFolder as alias
>
end tell
>
>
-- Fetch uploads the files in the alias list to the server specified
>
tell application "Fetch 3.0.3"
>
activate
>
make new transfer window at beginning with properties
>
{hostname:"host", userid:"user", password:"password", initial
>
directory:"Documents/TestUpload"}
>
set transfer mode of transfer window "host" to Binary
>
put into transfer window "host" item aVar
>
quit Application "Fetch 3.0.3"
>
end tell
>
>
-- moves folder to "Transfered" folder after it has been uploaded
>
tell application "Finder"
>
move item aVar to folder (desktop & "Transfered:")
>
end tell
>
end repeat
>
>
When I run the above script what I expect to happen is set SubFolder to
>
(SourceFolder & item m of SourceFolder) as text to set the path to
>
"HD:Desktop Folder:test:<folder1>". <folder1> is replaced each time the
>
next folder in the repeat loop. What happens is <folder1> is replaced
>
with the first letter of the path. So my hard drive's name is "HD" and
>
what happens is I get this path... "HD:DesktopFolder:test:H". The next
>
repeat will make the path "HD:DesktopFolder:test:D".
>
>
Is there something I am missing for the script to replace <folder1> with
>
folder names?
This should do the trick. It converts the Finder reference to an alias
reference while passing it to the "procFldr" handler.
tell application "Fetch 3.0.3"
activate
make new transfer window at beginning with properties [optn-L]
{hostname:"host", userid:"user", password:"password", initial directory:"Documents/TestUpload"}
set transfer mode of transfer window "host" to Binary
end tell
tell application "Finder"
set fldrList to folders of alias sourceFolder
repeat with aFldr in fldrList
my procFldr(aFldr as alias)
move aVar to folder (desktop & "Transfered:")
end repeat
end tell
tell application "Fetch 3.0.3" to quit
on procFldr(fldrAlias)
tell application "Fetch 3.0.3" to put into transfer window "host"
item fldrAlias
end procFldr
Note: "[optn-L]" stands in for the AppleScript continuation character.
Also watch for line wraps.
Marc K. Myers <email@hidden>
http://AppleScriptsToGo.com
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074
[12/20/01 12:08:43 PM]