Deleting an item from a property list

I'm trying to delete an item from a property list when it's name property begins with "_". The property list is a bunch of folders (fileDescriptions) from a network folder I have. The code is as follows:
put folders("\\networkFolder\share\testFolder") into subFolders

repeat with each item of subFolders
	
	if it.name begins with "_" then delete it from subFolders
	
end repeat

put subFolders

This code doesn't seem to be deleting the object from the list. Later on in the script I try and get the last modified folder using the NSFileModificationDate property but it returns a blank (which is the name of the deleted folder). If I don't delete the folder (by commenting out the code above) I get the name of the would be deleted folder as the last modified folder.

The result of "put subFolders" is troubling because the result has a comma at the end almost as if there's another object there.


I'm guessing that I'm not deleting the object from the property list correctly. Is it because I'm deleting it when I'm referring to the object as "it"?

Thanks for your help.

Comments

  • SenseTalkDougSenseTalkDoug ForumAdmin admin
    The simplest way to do this is to iterate through the list by reference. Then you can simply "delete it":
    repeat with each item of subFolders by reference
        
       if it.name begins with "_" then delete it 
        
    end repeat
    
    That should do what you want.
Sign In or Register to comment.