Page 1 of 1

Cannot get contents of plist files

PostPosted: Sun Jul 19, 2015 8:00 pm
by gwagener
I want to check the contents of the Info.plist file in an iPhone backup in ~/Library/Application Support/MobileSync/Backup/hash. I can quickview the file or open it in XCode and see the contents. I can also open it in Atom or TextEdit so it seems to be a plaintext encoded plist instead of one of the weird binary encoded plists. However, when I run it through hazelimporter I get the message:
Code: Select all
2015-07-20 11:47:46.484 hazelimporter[35690:3998288] Could not get text content of file: file:///Users/graham/Library/Application%20Support/MobileSync/Backup/bc902aa8dde721a48bd36c131ab737f0d498e377/Info.plist


Any suggestions?

OS X 10.10.4
Hazel 3.3.5 (build 1244)

Re: Cannot get contents of plist files

PostPosted: Mon Jul 20, 2015 11:08 am
by Mr_Noodle
It seems that plists aren't considered text files. If you do 'mdls' on it, you'll get a categorization like this:

kMDItemContentTypeTree = (
"com.apple.property-list",
"public.data",
"public.item"
)

There's nothing there to indicate that the file has text content unfortunately. You would have to temporarily rename it to a text type before Hazel would recognize it as such.

Re: Cannot get contents of plist files

PostPosted: Sun Oct 04, 2015 7:03 pm
by gwagener
Cheers. After figuring out how to use JavaScript to parse the iTunes music library I used the same approach to extract a value from the Info.plist.
Code: Select all
var infoURL = $.NSURL.fileURLWithPath(theFile.toString());
var info = $.NSXMLDocument.alloc.initWithContentsOfURLOptionsError(infoURL, 0, null);

var path = "dict/key/text()[.='Last Backup Date']/following::date";

var lastBackupDateString = ObjC.unwrap(info.rootElement.nodesForXPathError(path, null).firstObject.stringValue);
var lastBackupDate = new Date(lastBackupDateString);

return {
   'hazelOutputAttributes': [lastBackupDate],
   'hazelPassesScript': true
};