• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: renaming directories and moving files into them (NSFileManager)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: renaming directories and moving files into them (NSFileManager)


  • Subject: Re: renaming directories and moving files into them (NSFileManager)
  • From: Scott Anguish <email@hidden>
  • Date: Fri, 15 Apr 2011 02:51:48 -0400

On Apr 15, 2011, at 2:05 AM, Ken Thomases wrote:

> On Apr 15, 2011, at 12:47 AM, Scott Anguish wrote:
>
>> 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
>
> For what it's worth, I didn't follow that.
>

Sorry..

The directory is named a name derived from the file

so /tmp/boo/Friday

and when it encounters a file that has more specific information, it should be renamed

/tmp/boo/Friday-APPL

that should rename the existing directory with the existing fills and then copy all the new files to the new path name

>
>
>> 				newShootPath=[shootPath stringByAppendingString:@“-APPL”];
>> 				// make sure I’ve not already done this
>> 				if (![self directoryExists:newShootPath]) {
>>
>> 					success=[fileManager moveItemAtPath:shootPath toPath:newShootPath error:&theError];
>
> Why not log both shootPath and newShootPath right here, before the move?  What does it show?
>

It shows the correct values.

shootPath is /tmp/boo/Friday
newPath is /tmp/boo/Friday-APPL

the odd thing is the move is creating the /tmp/boo/Friday-APPL directory, rather than just renaming the existing one.


>> 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.
>
> Couldn't follow that, either, I'm afraid.  Perhaps you should just give the explicit set of paths of files, directories, etc. and which you want moved/renamed from where to where, and which are actually being moved/renamed from where to where.

I have

shootPath /tmp/boo/Friday

when the file is encountered the has the wherefrom that is associated with a Friday file, I want shootPath changed to

newPath /tmp/boo/Friday-APPL

and new files moved to there.

It’s the messed up behavior of moveItemAtPath:toPath:error: that is weirding me out.


—

The app works without the renaming of the directory, and I want feedback in the table as to what got moved and where. and since I need to use spotlight and don’t want to learn the necessary extras, how to access spotlight and such from a scripting language for a one-off-app, that’s why I’m doing this.

Yes, I could churn over the files, and I thought about it, but it seems like it shouldn’t be necessary. If I have to I can. But this seems like wrong move behavior which I should be diagnosing and then reporting.




_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: renaming directories and moving files into them (NSFileManager)
      • From: Ken Thomases <email@hidden>
    • Re: renaming directories and moving files into them (NSFileManager)
      • From: Ken Thomases <email@hidden>
    • Re: renaming directories and moving files into them (NSFileManager)
      • From: Laurent Daudelin <email@hidden>
References: 
 >renaming directories and moving files into them (NSFileManager) (From: Scott Anguish <email@hidden>)
 >Re: renaming directories and moving files into them (NSFileManager) (From: Ken Thomases <email@hidden>)

  • Prev by Date: Print Sheet: not changing when printinfo changed.
  • Next by Date: Searchable Cocoa and Carbon APIs?
  • Previous by thread: Re: renaming directories and moving files into them (NSFileManager)
  • Next by thread: Re: renaming directories and moving files into them (NSFileManager)
  • Index(es):
    • Date
    • Thread