Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use a unix-style syntax for copies names in Finder Desktop
When you duplicate an item (myfile.txt, for example) in the Finder, the duplicate's name becomes myfile copy.txt. If you're a Unix user, you might prefer to see the Unix-style copy syntax, which would be myfile~.txt.

To change the default copy name, navigate into /System -> Library -> CoreServices -> Finder.app -> [Control-click and Show Package Contents] -> Contents -> Resources -> English.lproj, and then open Localizable.strings with administrator privileges. Replace this line...
"N4" = "^0 copy";
...with this line:
"N4" = "^0~";
. Save your changes, quit the editor, and relaunch the Finder (Option-click-hold on its Dock icon, via Terminal, Activity Monitor, etc.).

Another thing you should know is that known extensions will make the tilde appear before the dot, while unknown extensions will produce a name like User.ini~. Pure old-school!

[robg adds: As with any system file modification, I strongly suggest you back up this file before modifying it. This file contains all of the Finder's responses to various events; you could tweak the heck out of your system by changing multiple lines in this file -- from a quick look, I think you could, amongst other things, rename the Sidebar, change the way labeled items are displayed, tweak various Spotlight search language, modify error messages, and tons more. One line of interest to me is this one:
"N2" = "untitled folder";
Change the untitled folder bit to something else, and you change where new folders appear in a sorted-by-name view. In my case, I set it to _• new folder (the underscore is really a space; I just wanted it to show here), which forces all new folders to the top of my column view windows.

The easiest way to edit this file is to drag it to your Desktop; this will make a copy, leaving the original in place. Make another duplicate and add "backup" or somesuch to its name. Now open the Desktop copy of the original, and make your changes. Save the changes, and drag the modified file back into the English.lproj folder, and answer the authenticate and replace dialogs as necessary. Note that this will change the permissions on the source file, though I've never had any issues it. If you run Disk Utility's Repair Permissions, all will be back to normal...]
    •    
  • Currently 2.50 / 5
  You rated: 4 / 5 (4 votes cast)
 
[10,664 views]  

Use a unix-style syntax for copies names in Finder | 7 comments | Create New Account
Click here to return to the 'Use a unix-style syntax for copies names in Finder' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use a unix-style syntax for copies names in Finder
Authored by: duffster on Dec 07, '05 07:43:14AM

Any of you Unix junkies know how I can add a date to the file name?

For instance, when I duplicate a file, I want the original to be "document.txt" and the dupe to be "document_051207_bak.txt".



[ Reply to This | # ]
Use a unix-style syntax for copies names in Finder
Authored by: TrumpetPower! on Dec 07, '05 10:01:19AM

Your best bet would be to write a Perl program. Catching all the possibilities of extensions, no extensions, files with dots in their names and extensions...well, anybody who's got enough awk-fu to do it in the shell knows that Perl's a better fit.

Hmmm...you'd also have to take bundles into account. You can't rely on simple rules like ``period and up to four letters at the end is an extension'' because of things like ``.webarchive.'' All in all, unless you're doing a /lot/ of this kind of thing, your best bet is to rely on human rather than artificial intelligence.

If you're just wondering how to get the date into the filename, something like `date +%Y-%m-%d` (note the backticks) will expand out as you'd expect. See the man page for date for details.

Cheers,

b&



[ Reply to This | # ]
Use a unix-style syntax for copies names in Finder
Authored by: TrumpetPower! on Dec 07, '05 10:09:07AM

I should expand upon that reply just a bit more. The hint will only work with static text, best I know. To get the current date into the filename, you'd need some code to figure out what the current date is and how you'd like to format it. The hint will also apply to /every/ file you copy in the Finder.

If you do a lot of this sort of versioning thing, you're really better off with some sort of revision control system. And, OS X being Unix, it just happens that it ships with exactly that--good ol' RCS. Read the man page ``rcsintro'' to learn everything you need to know. But, in day-to-day use, it's no harder than ``ci -l filename'' when you want to check in a file with changes worth saving. You can then later check out any previous version, see comments for the various versions, compare differences between any two versions--all that good stuff.

Cheers,

b&



[ Reply to This | # ]
Use a unix-style syntax for copies names in Finder
Authored by: sjk on Dec 08, '05 02:41:33PM

If speed isn't critical, you could create an Automator workflow for Finder to do the style of file duplication you'd like. I've got a simple one called "Rename with YYYY-MM-DD" that renames selected files with their modification year-month-day appended.



[ Reply to This | # ]
Use a unix-style syntax for copies names in Finder
Authored by: duffster on Dec 08, '05 04:53:29PM

Hmm...

Well, I'm supposed to get a new Mac sometime after New Years. Currently I'm hacking away on my old 700 MHz G3 iBook with Panther.

Automator sounds like the way for me to go. At least I know that I could handle it.



[ Reply to This | # ]
Use a unix-style syntax for copies names in Finder
Authored by: sjk on Dec 08, '05 07:40:18PM

I guess now you're waiting for Macworld before upgrading? I'm using a 600MHz iBook G3 (running 10.4.3) at the moment, my first Mac. I've since bought an eMac (mostly my wife's, shared with my EyeTV) and an iMac G5. I'll upgrade the iBook first, but I'm in no hurry unless it irreparably (by me; not going to pay to fix it) dies.

There's an Automator article on macworld.com (by Rob, I think) that can help you get started. It inspired me to write the Rename workflow. :-)



[ Reply to This | # ]
Use a unix-style syntax for copies names in Finder
Authored by: duffster on Dec 16, '05 05:55:23AM

Actually, my all-PC boss is waiting for the end of the year.

Currently, I'm taking my 700MHz G3 iBook in to work, because I prefer it to my Wintel.

I do have a Tiger G5 iMac at home, but don't feel the need to make copy file before I start to edit a text document. It's like living in a different country when you start working with people who are hardcore PCers.

So much time is wasted with Windows and FAT file structures.... *sigh*



[ Reply to This | # ]