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

Easily change a filename while the file is being edited System
Say you're working in Pages or TextEdit, but you want to change the filename of the document you're editing. In the past, I've done this with File » Save As, but then you wind up with two documents. Recently, I (re)discovered another cool way to rename an active file, one that leaves you with one file, and demonstrates the real-time connection between the file system and the app.

As an example, consider you're editing in TextEdit. Command-click on the title of the current window to see the pop-up menu attached to the title. From there, open the folder containing the file; this will open a Finder window showing that folder. In the opened folder, rename the file and close the window. When you go back to the TextEdit document, you'll see in the title bar that the filename now reflects the renamed file.

[robg adds: This has worked for, well, a really long time, but it's something that those new to the platform may not be aware of.]
    •    
  • Currently 1.71 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (7 votes cast)
 
[12,854 views]  

Easily change a filename while the file is being edited | 14 comments | Create New Account
Click here to return to the 'Easily change a filename while the file is being edited' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Easily change a filename while the file is being edited
Authored by: n1mie on Mar 13, '09 07:58:30AM

It may have been there for a long time, but that doesn't mean even long-time power users know about it. Thanks for sharing the obvious with the rest of us. I used to close the document, rename it, then reopen it. This is MUCH more elegant!

---
--Chip



[ Reply to This | # ]
Easily change a filename while the file is being edited
Authored by: sredlums on Mar 13, '09 08:19:57AM

One of the things I have allways liked about the Mac over Windows, is that you can do all kind of things to a file while it is open.
You can relocate it, give it a color-label, put some metadata in the info-window, even trash it, and the OS still doesn't bug you with errormessages.



[ Reply to This | # ]
Easily change a filename while the file is being edited
Authored by: unforeseen:X11 on Mar 17, '09 06:53:37AM

It didn't even occur to me that stuff like this could NOT be possible. Guess I'm lucky to have grow up with Macs. :)

---
this is not the sig you`re looking for.



[ Reply to This | # ]
This may have been around for quite a while...
Authored by: VesperDEM on Mar 13, '09 08:52:10AM

I have been a Mac person now for almost 3 years and I had no idea that this was possible.

As it turns out, it's not possible in all apps. I just tried it with TextMate and it didn't work. It does work with TextEdit. I wonder what other applications it doesn't work/does work with.

I suspect this is one of those: "Try it, if it works great, if not oh well..." kind of tips.



[ Reply to This | # ]
Easily change a filename while the file is being edited
Authored by: asmeurer on Mar 13, '09 09:45:27AM

I would try this before using it on something important. I think it works pretty standard in Cocoa applications, but you can get different results with different programs. For example, texmate will just change the name back for you, XCode will ask you if you want to resave the file (it's probably best to just close the file and then rename it if you are using XCode to edit it). The worst case scenario is that the program will crash because it can't "find" the file anymore. The same goes for moving a file while it is being edited.



[ Reply to This | # ]
Easily change a filename while the file is being edited
Authored by: ctwise on Mar 13, '09 10:31:57AM

This isn't an OS/X thing, it's a Unix thing. Unix file systems divorce the file name from the file contents. It's why the operating system call to delete a file is called 'unlink'. The file exists until all of the references to it are gone. You can even delete a file from the file system while a program has it open. It's a common paradigm in Unix programs to create a temporary scratch file, open it and then immediately delete it. No one but the program will have access to the file and it will completely disappear as soon as the program ends. That said, the applications have to be written to expect the name to change - so they can update titlebars, etc. In OS/X it looks like the application frameworks are written to expect this behavior.



[ Reply to This | # ]
Easily change a filename while the file is being edited
Authored by: outZider on Mar 15, '09 11:50:44AM

To be fair, this is an HFS thing as well. Macs since somewhere around the dawn of HFS in 1985 have been able to do this, and this is why Apple's API documentation tells you how to manage files by reference rather than by path. File references follow the file around the filesystem, and those people who ported apps from Windows, or didn't follow API guidelines by referencing a file by path end up breaking this ability in their application.

It's also a handy way to find out if an application was written in REALbasic, as 90% of those guys sit there writing "Macintosh HD:Applications:So On".



[ Reply to This | # ]
Easily change a filename while the file is being edited
Authored by: hankk on Mar 13, '09 11:58:15AM

Works for Preview.app. Very cool!

NB: At first I thought the filename in Preview hadn't changed after I renamed it in the Finder window. Then I noticed it doesn't change until you bring the Preview window back to the front again.



[ Reply to This | # ]
Easily change a filename while the file is being edited
Authored by: micmoo on Mar 13, '09 12:43:08PM

I've used a Mac everyday for my whole life (16 years) and I never knew this hint! Thanks for sharing!



[ Reply to This | # ]
Easily change a filename while the file is being edited
Authored by: mkhaw on Mar 13, '09 01:52:41PM

However, if you move the file in Finder while it's open for editing (at least in TextEdit on Tiger), the next time you save or quit, you'll get the open version saved in its old location. (Although it makes sense when I think about it, I've tripped myself up a few times that way. I don't recall what the interaction is between a file open for editing in vi/emacs and "mv"ing the file within the same filesystem.)



[ Reply to This | # ]
Easily change a filename while the file is being edited
Authored by: hamarkus on Mar 13, '09 04:50:31PM

The command-click on the filename in the title bar is helpful but in no way necessary. The key action is re-naming the file in the Finder and the application picking it up. Well, some apps pick up the new name (eg, TextWrangler), others ask when closing or saving the file, whether it should be saved under the old name.



[ Reply to This | # ]
Easily change a filename while the file is being edited
Authored by: Angus on Mar 14, '09 10:45:56AM

I've done this in BBEdit for a long time without issue. I do seem to recall it failing to work in some other apps though.



[ Reply to This | # ]
It even works with Pages…
Authored by: KuroRai on Mar 14, '09 07:09:58PM

When you change the name of a file (or move it) in Pages, it won't give you any bugs. When you go to save it will tell you, that the file has been renamed/moved, do you want to use the new information or create a new file (Save or Save As).

It's really helpful.



[ Reply to This | # ]
Easily change a filename while the file is being edited
Authored by: macgruder on Mar 15, '09 11:11:10PM

I've often told new OS X users to try command/control/etc clicking things to 'see what happens'. It's surprising how often you can discover such good stuff.

You can do this in the finder itself to get the file path, and in BBEdit there is a quicker way: simply click the file icon below the window bar.



[ Reply to This | # ]