Can't delete files in certain situation, but preview works

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

I'm creating symbolic links (via an applescript) from folderA to folderB and what I am trying to do is remove missing symbolic links from folder B after I delete the original in folderA.

I created a rule that says:
"if kind is not folder then delete", When I preview this rule all, it looks correct. The symbolic links that no longer have an original in folderA "pass" the rule. However, when I run the rule on folderB nothing happens. Any suggestions?
HerbDavisY2K
 
Posts: 7
Joined: Fri Dec 11, 2009 3:57 pm

I got this working by running this applescript rule on folderB (the one that contains all the symlinks)
This works with there are multiple symlinks that are missing their originals in folderA
Code: Select all
set SourceFolder to POSIX path of theFile
set myFind to do shell script "find -L " & quoted form of SourceFolder & " " & "-type l"
repeat with matchpath in paragraphs of myFind
   set myfiles to quoted form of matchpath
   try
      do shell script "rm " & myfiles
   end try
end repeat
Last edited by HerbDavisY2K on Sat May 22, 2010 1:00 pm, edited 1 time in total.
HerbDavisY2K
 
Posts: 7
Joined: Fri Dec 11, 2009 3:57 pm

Note that symbolic links are different than the things they point to. While you can navigate to it like a folder in Finder and in other places, they are different types of entities. Hazel treats links as links and not as the thing they point to.
Mr_Noodle
Site Admin
 
Posts: 11285
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Good to know. I'm using symbolic links because when using XBMC, alias files aren't treated like regular folders while symbolic links are.
HerbDavisY2K
 
Posts: 7
Joined: Fri Dec 11, 2009 3:57 pm

Do you mind sharing you AppleScript for symbolic links? I want to create them for current work folders, and then move the symlinks to Dropbox. Idea is to automate it so just the folders that have been modified recently get the symlinks, and the inactive ones are deleted from Dropbox.

Thanks!
gcoghill
 
Posts: 290
Joined: Tue Sep 18, 2007 8:09 am
Location: Kent, OH


Return to Support