I’m working on (what I assume to be) a reasonably sized AppleScript that is meant to sort files into folders based on their extension, among other things.
In working on this script, I have been having problems with lists I keep of files getting mangled if I tell the finder to move or delete any files that I am keeping track of in one of these lists. It seems to me that the file list gets shuffled to replace the file that is missing.
For example, let’s say that a folder contains files A, B, C, and D, and I am keeping aliases of files A and C in a list. If I then tell the finder to delete C, the second item in that list will now be D, and if I tell the finder to delete A, then the list will contain {B, D} rather than {A, C}
I figured that this had something to do with the items in the list being references to elements of some data structure that the Finder maintains, so I had a function that is supposed to work on these files make its own copy of the list of files the command
copy the contents of file_list to my_file_list
This worked in that function, but when I tried to implement the same fix at other points in my code, it didn’t seem to make a difference - both copies of the list get mangled in the same way.
If anyone could tell me a)what gives? b) how do I avoid this and c) how do I tell if I have a reference to a value or the value itself, I would love you forever.