I am setting up hazel to backup my Series folder into my hard drive. My goal is to have all my movies in my hard drive for backup, and only have the ones i'm interested in on my computer as they take a lot of space.
I can't use sync because it will delete files on my hard drive that don't exist on my computer, and I can't use copy because it will either delete files that aren't on my computer when replacing folders on the hard drive, or it will make too many copies of every file and that will take up too much space.
The solution was to go file-by-file. Again, using hazel to do this would be a pain, my series folder is structured in a particular way (Name_Of_Series/Season_num/*movies go here*) both in my movies folder and on my hard drive. I would have to create a copy of the same rule with a destination folder change for every season folder, which seems inefficient to me.
I went on to create an applescript. This applescript will take the path of theFile, filter out the beginning of the name so that only the part /Name_Of_Series/Season_Num/Movie_File remains, then adds it to the path to my series folder in my hard drive. It then checks whether the file exists or not, returning false if it does ( as I do not want to copy the file if it already exists) and true if it doesn't (and then should go on to copy the file).
When I input the first path manually and run that inside applescript editor, it works perfectly well
- Code: Select all
set f to "Macintosh HD:jonathanhirsch:Movies:Torrent Series:Dexter:Season 3:Dexter - S03E10.mkv" as string
set num to get number of characters in f
set pathName to characters 51 through num of f as string
set exist to null
try
set HDf to "Macintosh HD:Volumes:Jono:Series:" & pathName as string
set f2 to HDf as alias
set exist to false
on error
set exist to true
end try
return exist
but when I put it inside hazel, changing 'set f to "Macintosh HD:jonathanhirsch:Movies:Torrent Series:Dexter:Season 3:Dexter - S03E10.mkv" as string' to 'set f to path to theFile as string', hazel returns an error. If I check the preview of the rule, it says that there is a no metadata error.

note: the applescript rule that is supposed to run if the file matches just creates a file in my home directory so that I know whether the rule matched or not. It doesn't move anything. Also, I filtered out names of episodes so that just one would match and prevent spamming and slowing down because all my movies would return errors. I plan to run this rule also only if the folder was modified before the last time hazel checked so that it does not run it too often.
and here are the logs for that file (with debug). They seem huge for the small amount of work I actually thought it would do..
- Code: Select all
2012-07-17 23:55:24.285 hazelworker[6947] DEBUG: [PREDICTION] Predicted fire time for file: /Users/jonathanhirsch/Movies/Torrent Series/Dexter/Season 3 and rule Go into Folders: 5828963-12-20 08:00:00.000 Should poll: 0
2012-07-17 23:55:24.285 hazelworker[6947] DEBUG: Recursing into directory: /Users/jonathanhirsch/Movies/Torrent Series/Dexter/Season 3
2012-07-17 23:55:24.286 hazelworker[6947] DEBUG: .DS_Store: File is hidden/invisible. Skipping.
2012-07-17 23:55:24.288 hazelworker[6947] DEBUG: [PREDICTION] Calculating fire time - predicate: labelColor ==[cd] 7 negation: 0 result: 0
2012-07-17 23:55:24.288 hazelworker[6947] DEBUG: [PREDICTION] Next fire time: 5828963-12-20 08:00:00.000
2012-07-17 23:55:24.288 hazelworker[6947] DEBUG: [PREDICTION] Bail out: AND predicate
2012-07-17 23:55:24.288 hazelworker[6947] DEBUG: [PREDICTION] Predicted fire time for file: /Users/jonathanhirsch/Movies/Torrent Series/Dexter/Season 3/Dexter - S03E01.mkv and rule Not All Seen: 5828963-12-20 08:00:00.000 Should poll: 0
2012-07-17 23:55:24.290 hazelworker[6947] DEBUG: [PREDICTION] Calculating fire time - predicate: typeObject isType: "public.folder" negation: 0 result: 0
2012-07-17 23:55:24.290 hazelworker[6947] DEBUG: [PREDICTION] Next fire time: 5828963-12-20 08:00:00.000
2012-07-17 23:55:24.290 hazelworker[6947] DEBUG: [PREDICTION] Bail out: AND predicate
2012-07-17 23:55:24.290 hazelworker[6947] DEBUG: [PREDICTION] Predicted fire time for file: /Users/jonathanhirsch/Movies/Torrent Series/Dexter/Season 3/Dexter - S03E01.mkv and rule Go into Folders: 5828963-12-20 08:00:00.000 Should poll: 0
2012-07-17 23:55:24.291 hazelworker[6947] DEBUG: [PREDICTION] Calculating fire time - predicate: displayExtension ==[cd] "torrent" negation: 0 result: 0
2012-07-17 23:55:24.291 hazelworker[6947] DEBUG: [PREDICTION] Next fire time: 5828963-12-20 08:00:00.000
2012-07-17 23:55:24.291 hazelworker[6947] DEBUG: [PREDICTION] Bail out: AND predicate
2012-07-17 23:55:24.291 hazelworker[6947] DEBUG: [PREDICTION] Predicted fire time for file: /Users/jonathanhirsch/Movies/Torrent Series/Dexter/Season 3/Dexter - S03E01.mkv and rule Rename Torrents: 5828963-12-20 08:00:00.000 Should poll: 0
2012-07-17 23:55:24.291 hazelworker[6947] DEBUG: [PREDICTION] Calculating fire time - predicate: displayExtension ==[cd] "torrent" negation: 0 result: 0
2012-07-17 23:55:24.291 hazelworker[6947] DEBUG: [PREDICTION] Next fire time: 5828963-12-20 08:00:00.000
2012-07-17 23:55:24.291 hazelworker[6947] DEBUG: [PREDICTION] Bail out: AND predicate
2012-07-17 23:55:24.292 hazelworker[6947] DEBUG: [PREDICTION] Predicted fire time for file: /Users/jonathanhirsch/Movies/Torrent Series/Dexter/Season 3/Dexter - S03E01.mkv and rule Open Torrents: 5828963-12-20 08:00:00.000 Should poll: 0
2012-07-17 23:55:24.293 hazelworker[6947] DEBUG: [PREDICTION] Calculating fire time - predicate: typeObject isType: "public.movie" negation: 0 result: 1
2012-07-17 23:55:24.293 hazelworker[6947] DEBUG: [PREDICTION] Next fire time: 5828963-12-20 08:00:00.000
2012-07-17 23:55:24.293 hazelworker[6947] DEBUG: [PREDICTION] Calculating fire time - predicate: displayBasename hazelContainsObject: "dexter" negation: 0 result: 1
2012-07-17 23:55:24.293 hazelworker[6947] DEBUG: [PREDICTION] Next fire time: 5828963-12-20 08:00:00.000
2012-07-17 23:55:24.385 hazelworker[6947] [Error] Error during rule evaluation: Received error while trying to evaluate rule Copy to Hard Drive on file Dexter - S03E01.mkv
2012-07-17 23:55:24.387 hazelworker[6947] Error while matching rule Copy to Hard Drive against file /Users/jonathanhirsch/Movies/Torrent Series/Dexter/Season 3/Dexter - S03E01.mkv: Error executing AppleScript: {
NSLocalizedDescription = "Can\U2019t make alias \"Macintosh HD:Users:jonathanhirsch:Movies:Torrent Series:Dexter:Season 3:Dexter - S03E01.mkv\" into type constant.";
NSLocalizedFailureReason = "Can\U2019t make alias \"Macintosh HD:Users:jonathanhirsch:Movies:Torrent Series:Dexter:Season 3:Dexter - S03E01.mkv\" into type constant.";
OSAScriptErrorAppAddressKey = "<NSAppleEventDescriptor: [0x0,2 \"hazelworker\"]>";
OSAScriptErrorAppNameKey = hazelworker;
OSAScriptErrorBriefMessageKey = "Can\U2019t make alias \"Macintosh HD:Users:jonathanhirsch:Movies:Torrent Series:Dexter:Season 3:Dexter - S03E01.mkv\" into type constant.";
OSAScriptErrorExpectedTypeKey = "<NSAppleEventDescriptor: 'enum'>";
OSAScriptErrorMessageKey = "Can\U2019t make alias \"Macintosh HD:Users:jonathanhirsch:Movies:Torrent Series:Dexter:Season 3:Dexter - S03E01.mkv\" into type constant.";
OSAScriptErrorNumberKey = "-1700";
OSAScriptErrorOffendingObjectKey = "<NSAppleEventDescriptor: 'alis'(488/360000000001E8000200000C4D6163696E746F7368204844000000000000000000000000000000CBB434C5482B00000136030313446578746572202D205330334530312E6D6B7600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000136030ACBF2FC5E0000000000000000FFFFFFFF0000092000000000000000000000000000000008536561736F6E2033001000080000CBB3C4450000001100080000CBF28BDE0000000100180136030301215A51002C5F0E00044B7200044AAB0000BF11000200614D6163696E746F73682048443A55736572733A006A6F6E617468616E6869727363683A004D6F766965733A00546F7272656E74205365726965733A004465787465723A00536561736F6E20333A00446578746572202D205330334530312E6D6B7600000E002800130044006500780074006500720020002D0020005300300033004500300031002E006D006B0076000F001A000C004D006100630069006E0074006F007300680020004800440012004E55736572732F6A6F6E617468616E6869727363682F4D6F766965732F546F7272656E74205365726965732F4465787465722F536561736F6E20332F446578746572202D205330334530312E6D6B76001300012F00001500020015FFFF000036)>";
OSAScriptErrorRangeKey = "NSRange: {0, 0}";
}
2012-07-17 23:55:24.388 hazelworker[6947] DEBUG: Tapping error retry sequence
2012-07-17 23:55:24.389 hazelworker[6947] (
0 CoreFoundation 0x00007fff93c9bc96 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff91b7c444 objc_exception_throw + 43
2 CoreFoundation 0x00007fff93c9ba6c +[NSException raise:format:] + 204
3 hazelworker 0x00000001000172c5 start + 89385
4 Foundation 0x00007fff9360d3f8 -[NSCustomPredicateOperator performPrimitiveOperationUsingObject:andObject:] + 50
5 Foundation 0x00007fff935d416c -[NSPredicateOperator performOperationUsingObject:andObject:] + 116
6 Foundation 0x00007fff935d3aed -[NSComparisonPredicate evaluateWithObject:substitutionVariables:] + 302
7 Foundation 0x00007fff935d35e8 -[NSPredicate evaluateWithObject:] + 19
8 hazelworker 0x0000000100037f8b start + 223727
9 hazelworker 0x0000000100037c90 start + 222964
10 hazelworker 0x000000010003d0a7 start + 244491
11 hazelworker 0x000000010003752f start + 221075
12 hazelworker 0x000000010000278e start + 4594
13 hazelworker 0x00000001000036a4 start + 8456
14 hazelworker 0x00000001000065cc start + 20528
15 hazelworker 0x00000001000015d0 start + 52
16 ??? 0x0000000000000003 0x0 + 3
)
2012-07-17 23:55:24.389 hazelworker[6947] DEBUG: [PREDICTION] Predicted fire time for file: /Users/jonathanhirsch/Movies/Torrent Series/Dexter/Season 3/Dexter - S03E01.mkv and rule Copy to Hard Drive: 5828963-12-20 08:00:00.000 Should poll: 0
2012-07-17 23:55:24.392 hazelworker[6947] DEBUG: [PREDICTION] Calculating fire time - predicate: dateAccessed hazelIsInTheLast: 1 Week negation: 1 result: 0
2012-07-17 23:55:24.393 hazelworker[6947] DEBUG: [PREDICTION] Date value: 2012-07-13 06:47:02 +0000 Ref date: 2012-07-17 15:55:24 +0000
2012-07-17 23:55:24.394 hazelworker[6947] DEBUG: [PREDICTION] Handling CUSTOM SELECTOR
2012-07-17 23:55:24.394 hazelworker[6947] DEBUG: [PREDICTION] Next fire time: 2012-07-20 14:47:02.939
2012-07-17 23:55:24.394 hazelworker[6947] DEBUG: [PREDICTION] Calculating fire time - predicate: dateAccessed hazelIsEmpty: <null> negation: 1 result: 1
2012-07-17 23:55:24.395 hazelworker[6947] DEBUG: [PREDICTION] Date value: 2012-07-13 06:47:02 +0000 Ref date: 2012-07-17 15:55:24 +0000
2012-07-17 23:55:24.395 hazelworker[6947] DEBUG: [PREDICTION] Handling CUSTOM SELECTOR
2012-07-17 23:55:24.396 hazelworker[6947] DEBUG: [PREDICTION] Next fire time: 5828963-12-20 08:00:00.000
2012-07-17 23:55:24.396 hazelworker[6947] DEBUG: [PREDICTION] Predicted fire time for file: /Users/jonathanhirsch/Movies/Torrent Series/Dexter/Season 3/Dexter - S03E01.mkv and rule Old File: 2012-07-20 14:47:02.939 Should poll: 1
2012-07-17 23:55:24.396 hazelworker[6947] DEBUG: [PREDICTION] Calculating fire time - predicate: dateAccessed >[cd] dateModified negation: 0 result: 1
2012-07-17 23:55:24.400 hazelworker[6947] DEBUG: [PREDICTION] Date value: 2012-07-13 06:47:02 +0000 Ref date: 2012-07-17 15:55:24 +0000
2012-07-17 23:55:24.400 hazelworker[6947] DEBUG: [PREDICTION] Handling GREATER THAN/TRUE
2012-07-17 23:55:24.400 hazelworker[6947] DEBUG: [PREDICTION] Next fire time: 5828963-12-20 08:00:00.000
2012-07-17 23:55:24.401 hazelworker[6947] DEBUG: [PREDICTION] Calculating fire time - predicate: typeObject isType: "public.movie" negation: 0 result: 1
2012-07-17 23:55:24.401 hazelworker[6947] DEBUG: [PREDICTION] Next fire time: 5828963-12-20 08:00:00.000
2012-07-17 23:55:24.401 hazelworker[6947] DEBUG: [PREDICTION] Calculating fire time - predicate: labelColor !=[cd] 1 negation: 0 result: 1
2012-07-17 23:55:24.401 hazelworker[6947] DEBUG: [PREDICTION] Next fire time: 5828963-12-20 08:00:00.000
2012-07-17 23:55:24.402 hazelworker[6947] DEBUG: [PREDICTION] Calculating fire time - predicate: labelColor !=[cd] 0 negation: 0 result: 0
2012-07-17 23:55:24.402 hazelworker[6947] DEBUG: [PREDICTION] Next fire time: 5828963-12-20 08:00:00.000
2012-07-17 23:55:24.402 hazelworker[6947] DEBUG: [PREDICTION] Bail out: AND predicate
2012-07-17 23:55:24.402 hazelworker[6947] DEBUG: [PREDICTION] Bail out: AND predicate
2012-07-17 23:55:24.402 hazelworker[6947] DEBUG: [PREDICTION] Predicted fire time for file: /Users/jonathanhirsch/Movies/Torrent Series/Dexter/Season 3/Dexter - S03E01.mkv and rule Opened: 5828963-12-20 08:00:00.000 Should poll: 0
2012-07-17 23:55:24.402 hazelworker[6947] DEBUG: [PREDICTION] Calculating fire time - predicate: dateModified >[cd] dateAccessed negation: 0 result: 0
2012-07-17 23:55:24.403 hazelworker[6947] DEBUG: [PREDICTION] Date value: 2012-06-10 15:46:54 +0000 Ref date: 2012-07-17 15:55:24 +0000
2012-07-17 23:55:24.403 hazelworker[6947] DEBUG: [PREDICTION] Handling LESS THAN/TRUE or GREATER THAN/FALSE
2012-07-17 23:55:24.403 hazelworker[6947] DEBUG: [PREDICTION] Next fire time: 5828963-12-20 08:00:00.000
2012-07-17 23:55:24.403 hazelworker[6947] DEBUG: [PREDICTION] Bail out: AND predicate
2012-07-17 23:55:24.403 hazelworker[6947] DEBUG: [PREDICTION] Calculating fire time - predicate: labelColor ==[cd] 1 negation: 0 result: 0
2012-07-17 23:55:24.403 hazelworker[6947] DEBUG: [PREDICTION] Next fire time: 5828963-12-20 08:00:00.000
2012-07-17 23:55:24.403 hazelworker[6947] DEBUG: [PREDICTION] Bail out: AND predicate
2012-07-17 23:55:24.403 hazelworker[6947] DEBUG: [PREDICTION] Predicted fire time for file: /Users/jonathanhirsch/Movies/Torrent Series/Dexter/Season 3/Dexter - S03E01.mkv and rule Recently modified: 5828963-12-20 08:00:00.000 Should poll: 0
2012-07-17 23:55:24.403 hazelworker[6947] DEBUG: Dexter - S03E01.mkv: Did not match any rules.
2012-07-17 23:55:24.405 hazelworker[6947] DEBUG: [PREDICTION] Calculating fire time - predicate: labelColor ==[cd] 7 negation: 0 result: 0
2012-07-17 23:55:24.405 hazelworker[6947] DEBUG: [PREDICTION] Next fire time: 5828963-12-20 08:00:00.000
2012-07-17 23:55:24.405 hazelworker[6947] DEBUG: [PREDICTION] Bail out: AND predicate
Thanks!