Mr_Noodle wrote:You might be able to rig something using the source folder attribute. Something like:
- Move the file to the "mirror" folder.
- Create the alias at the monitored folder.
- Sort into subfolder (which would be the alias) using the "source folder" attribute, setting it from the monitored folder.
That said, I'd advise against manipulating files after you imported them into Aperture. They are Aperture's data files at that point and while it may seem to work now, it is a bit risky and can break.
Unfortunately, something goes wrong with the path when the aliases are moved. Here is a test configuration and the result of the rule set:
Before applying the rules:
The Monitored Folder "HazelTest" is located in Documents. It contains the following subfolders and files:
/2008/testFile_2008.mp4
/2009/2009-12-03/testFile_2009-12-03.mp4
/2009/2009-12-12/testFile_2009-12-12.mp4
The target folder for the move is "Movies - Test," located within Movies. The target folder is initially empty.
Hazel rules for the monitored folder:
Rule 1:
If all of the following conditions are met
Kind is folder
Do the following to the matched file or folder:
Run rules on folder contents
Rule 2:
If all of the following conditions are met
Kind is Movie
Do the following to the matched file or folder:
Move to folder: "Movies - Test" with option: copy folder structure: "from monitored folder"
Make alias in folder: "enclosing folder"
Sort into subfolder with pattern: "source folder" with option "use path from monitored folder"
After applying the rules:
All folders in Documents/HazelTest are empty
The target folder Movies/Movies - Test now contains:
2008/testFile_2008.mp4
2008/testFile_2008-1.mp4 (alias)
2009/2009-12-03/testFile_2009-12-03.mp4
2009/2009-12-12/testFile_2009-12-12.mp4
2009/2009/2009-12-03/testFile_2009-12-03-1.mp4 (alias)
2009/2009/2009-12-12/testFile_2009-12-12-1.mp4 (alias)
So the files were moved as expected but the aliases were not moved back to the original location. Additionally there seems to be an issue with the nesting level for the contents of the 2009 folder.
I'm now trying to run an AppleScript to create the alias before the file gets moved. For some reason, the following generates an error:
- Code: Select all
tell application "Finder" to make new alias at (path to theFile) to file (theFile)
2013-12-30 18:31:24.296 hazelworker[16782] 2009-12-12: Rule Tree matched.
2013-12-30 18:31:24.299 hazelworker[16782] testFile_2009-12-12.mp4: Rule Move movie file and keep alias using AppleScript matched.
2013-12-30 18:31:24.483 hazelworker[16782] [Error] AppleScript failed: Error executing AppleScript on file /Users/X-C-L/Documents/HazelTests/2009/2009-12-12/testFile_2009-12-12.mp4.
2013-12-30 18:31:24.483 hazelworker[16782] AppleScript error: {
NSLocalizedDescription = "Finder got an error: Can\U2019t make alias \"Macintosh HD:Users:X-C-L:Documents:HazelTests:2009:2009-12-12:testFile_2009-12-12.mp4\" into type constant.";
NSLocalizedFailureReason = "Can\U2019t make alias \"Macintosh HD:Users:X-C-L:Documents:HazelTests:2009:2009-12-12:testFile_2009-12-12.mp4\" into type constant.";
OSAScriptErrorAppAddressKey = "<NSAppleEventDescriptor: [0x0,10010 \"Finder\"]>";
OSAScriptErrorAppNameKey = Finder;
OSAScriptErrorBriefMessageKey = "Can\U2019t make alias \"Macintosh HD:Users:X-C-L:Documents:HazelTests:2009:2009-12-12:testFile_2009-12-12.mp4\" into type constant.";
OSAScriptErrorExpectedTypeKey = "<NSAppleEventDescriptor: 'enum'>";
OSAScriptErrorMessageKey = "Finder got an error: Can\U2019t make alias \"Macintosh HD:Users:X-C-L:Documents:HazelTests:2009:2009-12-12:testFile_2009-12-12.mp4\" into type constant.";
OSAScriptErrorNumberKey = "-1700";
OSAScriptErrorOffendingObjectKey = "<NSAppleEventDescriptor: 'alis'($00...
hexadecimal gibberish ... 00$)>";
OSAScriptErrorRangeKey = "NSRange: {0, 0}";
}
Time for me to learn a bit more AppleScript...
Regarding Aperture's behavior: In my case I don't let Aperture move new files into the Aperture library. They go instead into subfolders in the Pictures folder. This makes life easier for backup purposes. The Aperture library itself contains thumbnails, previews and faces. With this setup Aperture does not lose track of files when I move them manually or rename them with Finder. I was hoping this behavior would be preserved when using Hazel.
Xavier