Hello all. Here is a small piece of script that crashes my machine every time I try to run it. I am trying to get a list of file names that do not have a bullet in them. It is a slight variation of an existing, working script. The only different is the use of the command “whose” in the “set theList to get…” line.
Any suggestions?
Thanks, Ivey
set thisURL to "ftp://username:password@ftp.o'mydreams.com/folder"
tell application "Fetch 3.0.2"
open remote item thisURL --opens first destination
set theList to (get every remote file in transfer window 1)¬
whose (name does not contain "•")
end tell
return theList
Could you check the class of the window 1, you may not be working in a transfer window. I’m working with Fetch 4.0.2 and cannot reproduce your error. Jean-Baptiste LE STANG
Okay. I can get the class of the window and apparently, it is “window”. Not “transfer window”. Is this correct?
I’ve altered the script a bit, and am now getting a different error message. I added an “activate” command to make sure the Fetch program is the foremost application. The error message now reads: “Fetch got an error: Wrong keyword for a special function.”
Changing “item” instead of “file” results in the same error message, so I am still stumped on the keyword.
tell application "Fetch 3.0.2"
activate
open remote item thisURL --opens first destination
get class of window 1
set theList to (get every remote file in transfer window 1) whose (name does not contain "•")
end tell
The problem is that you’re using terms that refers to a transfer window that does not exist. that’s where (i think) is the problem, I’m still working on it. Jean-Baptiste LE STANG
Here’s one solution, but what is bothering me is that first I refer to remote file of transfer window 1 and then to remote file x without precising that it’s the one in the transfer window, that was where I was stuck. There might be an other solution… Jean-Baptiste LESTANG
tell application “Fetch 4.0.1”
activate
set ListOfNames to {}
repeat with x from 1 to count (remote file of transfer window 1)
set CurrentName to name of (remote file x)
if “.” is not in CurrentName then
set ListOfNames to ListOfNames & CurrentName
end if
end repeat end tell
I’ve tried changing “transfer window 1” to just “window” or “front window”, but neither of them work either.
The script that does work has the operation broken down into two separate functions. I’ve attached it here. Maybe it will spark an idea.
Ivey
tell application "Fetch 3.0.2"
open remote item thisURL --opens first destination
set theList to (get name of every remote file in transfer window 1) --gets names of the files only, ignores folders
end tell
set revisedList to {} --sets list to empty for start of process
repeat with anItem in theList --cycles through entire list for files that need to be worked on
if ("•" is not in anItem) then --if the name has a bullet, it has already been downloaded
set revisedList to revisedList & anItem --collects unbulleted names in a new list
end if
end repeat
This works, however! Wonderful! Thank you.
The script is actually faster with your variation. I think it is because the script doesn’t have to remember the entire list of names and THEN check for bullets; it makes that decision with each file as it comes across it.
I find it interesting that it works even though the script refers to (“remote file” of transfer window 1) instead of (“remote files” of transfer window 1). I’ve tried changing it, but the script really wants just the single reference. That is strange.
Thanks again, Ivey
I think that’s not the only thing that’s strange with Fetch. I had a lot of difficulties to find the right syntax. I had to uses Script Debugger (only the demo but it’s doing the work well) in order to be able to watch what was the state of Fetch. Jean-Baptiste LE STANG