1

I have to change file names a lot, but Windows won't let you change them when they're open. I know I can exit and rename the file after, or Save As with a different name, but this just seems like bad design.

Is anyone aware of a better workaround?

Tetsujin
  • 47,296
  • 8
  • 108
  • 135
Alec McKay
  • 31
  • 4
  • 1
    None that I have ever found, – Moab Nov 09 '19 at 19:41
  • Related: [How can I rename files and folders in windows that are in use?](https://superuser.com/questions/54193/how-can-i-rename-files-and-folders-in-windows-that-are-in-use) – Mokubai Nov 09 '19 at 21:18

1 Answers1

2

Your premise is false. Files cannot be renamed if they are intentionally locked, a feature of many operating systems, including Linux and Windows, to prevent unpredictable results when trying to write to a file.

However, many applications, such as Notepad++ (NPP), can open a file read-only, not requiring a lock. Test this yourself: open a file in NPP and, with the file left open, rename it.

For your edification, you can peruse the Windows OpenFile constants, such as:

  • OF_READWRITE - Opens a file with read and write permissions.
  • OF_SHARE_DENY_NONE - Opens a file but allows other processes read and write acces.
  • OF_SHARE_EXCLUSIVE - Opens a file, denying both read and write access to other processes.
DrMoishe Pippik
  • 25,661
  • 4
  • 36
  • 54