Scott, are you copying the files asynchronously? I wonder if there are some files still in the process of being copied to the old directory, so the old directory either doesn't really go away, or it gets recreated. What happens if you comment out the actual copying of the files? And if you log the names of the files as they are copied, which ones go to /tmp/boo/Friday and which go to /tmp/boo/Friday-AAPL, relative to the point where you call moveItemAtPath:toPath:error:?
--Andy On Apr 15, 2011, at 1:47 AM, Scott Anguish wrote: > OK, before anyone asks... I’m working on a tool for my own use, and so I > don’t want to bug people at work about it. > > Thus, I bug you. :-) > > I’m perplexed by this one. > > I’m trying something stupidly simple, and I’m getting really odd results. > > I have an app that sorts a bunch of files and sticks them in a newly made > directories. When it finds a file that identifies WhereFroms (via spotlight, > from a downloaded file) I want it to rename that directory and then copy the > rest of the related files into that directory > > All this seems really straight forward. I’m using NSFileManager > moveItemAtPath:toPath:error: > > Code, whittled down to the important stuff.. > > shootPath is the original path that things are getting copied to. (for > example /tmp/boo/Friday) and files are copied into that. > > if ([[eachPath pathExtension] isEqualToString:@"mp4"]) { > > MDItemRef > fileMetadata=MDItemCreate(NULL,(CFStringRef)eachPath); > NSDictionary *metadataDictionary= > (NSDictionary*)MDItemCopyAttributes (fileMetadata,(CFArrayRef)[NSArray > arrayWithObject:(id)kMDItemWhereFroms]); > > NSString *whereFrom=[[metadataDictionary > objectForKey:(id)kMDItemWhereFroms] lastObject]; > > NSURL *whereFromURL=[NSURL URLWithString:whereFrom]; > > NSString *rawDomain=[whereFromURL host]; > NSRange foundRange=[rawDomain rangeOfString:@“apple" > options:(NSCaseInsensitiveSearch)]; > NSLog(@"foundRange - > %d,%d",foundRange.location,foundRange.length); > > // all the above works fine > > if (foundRange.location > 0) { // should be comparing > to NSNotFound, but that failed miserably. > newShootPath=[shootPath > stringByAppendingString:@“-APPL”]; > // make sure I’ve not already done this > if (![self directoryExists:newShootPath]) { > > success=[fileManager > moveItemAtPath:shootPath toPath:newShootPath error:&theError]; > NSLog(@"should be moving - %d",success); > //success is true! > > // make the newShootPath, the shootPath > for other files > [shootPath autorelease]; > shootPath=[newShootPath retain]; > > // this just updates a table for > progress > if (!success) > tempTableitem.error=theError; > [self > addObjectToTableContents:tempTableitem]; > [tempTableitem release]; > theError=nil; > } > } > } > > It always creates a new directory wit the new name, in the existing shootPath > directory (for example /tmp/boo/Friday) with Friday-APPL instead. and then > copies the newly found files into that. I’m boggled. > > what am I missing? > > Any ideas_______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > http://lists.apple.com/mailman/options/cocoa-dev/aglee%40mac.com > > This email sent to ag...@mac.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com