Re: Automatic file numbering ideas...
Re: Automatic file numbering ideas...
- Subject: Re: Automatic file numbering ideas...
- From: douglas welton <email@hidden>
- Date: Sun, 23 Nov 2008 21:17:31 -0500
I might try some of the following:
1) use the NSGlobalDomain to store the counting data.
2) implement the functionality as a service (like grab does)
3) build a small helper application and let it do all the work.
4) implement the counting data in a single file (at some commonly
known location) instead of the user defaults.
regards,
douglas
On Nov 23, 2008, at 9:00 PM, Andrew Merenbach wrote:
Hi, Douglas,
That's not a bad idea, but would this not be a problem if the prefix
(e.g., "Picture") were shared by another program, such as the
system's screen-grabbing functionality? Also, if someone
deliberately puts a file on the Desktop and names it "Picture 5", it
could get overwritten if we don't check for it -- in which case
we're back to square one, checking each time through our loop for a
filename's existence. Unless I'm misunderstanding... which I have a
tendency to do!
Cheers,
Andrew
On Nov 23, 2008, at 5:51 PM, douglas welton wrote:
Jean-Nicolas.
Have you considered the notion of keeping your "counting data" in
the user defaults? This would give you quick persistence, without
having to calculate a value using the contents of a directory.
Each time you create a new file, increment the counting data and re-
store the new value in the user defaults. You could do a rollover
check once your count gets to some arbitrary value (say 100).
Note: This assumes that you want your count to be universal/system-
wide. If you want it to be directory specific, you might implement
the same scheme with tuples of directory paths and count values.
Also, I assume that you always want to count up... meaning that if
you have files picture 1, picture 2, and picture 4 in a directory,
then the next file is "picture 5", not "picture 3"
regards,
douglas
On Nov 23, 2008, at 1:45 PM, Jean-Nicolas Jolivet wrote:
I would love to implement something like the default screenshot
utility for OS X does when it names its pictures.. (i.e. Picture
1, Picture 2, Picture 3.. etc.)
I was wondering if there's already something in place to do that?
If not, I don't mind implementing it myself but I can't really
think of a simple way to do it? Counting the files in a directory
is not really a reliable way to do it (i.e. if you have Picture 2
and Picture 3 in a directory, your count is 2... try naming your
new picture Picture 3 and it overwrites the existing Picture 3 ...)
I'm fairly good with RegEx so it would be easy to parse filenames
for numbers I guess but it seems a little overkill for such a
trivial task... (especially since my app wouldn't use Regex for
anything else so, I dont want to add a regex framework just for
that)...
Any ideas would be appreciated?
Jean-Nicolas Jolivet
email@hidden
http://www.silverscripting.com
_______________________________________________
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
_______________________________________________
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