7

When you create, or copy many objects with the same name
— Windows numerates them in round brackets automatically, like this:

New folder
New folder (2)
New folder (3), etc.

Or this:

New folder — copy
New folder — copy (2)
New folder — copy (3), etc.

The problem (!!!) reveals when initial object already has such number in its name:

New folder (2)
New folder (2) — copy
New folder (3) — copy
New folder (4) — copy, etc.

Instead of:

New folder (2)
New folder (2) — copy
New folder (2) — copy (1)
New folder (2) — copy (2), etc.

So, Windows doesn't actually care about saving original name of the object: it uses the first round brackets that are available (say, before the sign).

To start solving this one can go to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\NamingTemplates
and create RenameNameTemplate and CopyNameTemplate string values with desirable names (source).

That made me wonder if someone can help me with any of these solutions:

  1. Find another registry key to modify that "numeration" feature.

  2. Or use some magic words inside NamingTemplates to mask, say, a time and date of creation in the object's name; something like this:

    New folder %year.%month.%day %hours-%minutes 00 %seconds
    New folder %year.%month.%day %hours-%minutes 01 %seconds
    New folder %year.%month.%day %hours-%minutes 02 %seconds, etc.
    
Franck Dernoncourt
  • 24,246
  • 64
  • 231
  • 400

4 Answers4

2

You can do something like this with the Totalcommander shareware, using the built-in Multi-rename-Tool. In the picture below you can see an example, formatted as in your question.

enter image description here

The clear advantage over any Windows registry feature, and reason why I add this here, is that you can easily change the command to your needs in different situations. Totalcommander even allows you to save separate templates as separate commands, for different use cases.

While this is not free software, the evaluation copy you can download is fully functional.

Franck Dernoncourt
  • 24,246
  • 64
  • 231
  • 400
1NN
  • 10,044
1

To add the time and date to the default file name template in Windows, you can use the following steps:

  • Right-click on the desktop or in a folder where you want to create a new file.

  • Select "New" and then "Text Document" or any other type of file you want to create.

  • Right-click on the new file and select "Rename".

  • Change the file name to something like "New File [date] [time].txt" or "New File year-month-day hour-minute-second.txt".

  • Press the "F2" key to make the file name editable.

  • Hold down the "Alt" key and type the following codes on the numeric keypad:

    [date]: 010 (dd/mm/yy format) or 012 (mm/dd/yy format)

    [time]: 014 (hh:mm format) or 015 (hh:mm:ss format)

  • Release the "Alt" key and press "Enter" to save the changes to the file name.

  • The time and date will be automatically inserted into the file name.

Rohit Gupta
  • 5,096
0

Changing the NamingTemplate (for Copy or Rename) is not going to work, as you have discovered. The only argument to 'printf' or the equivalent function it is using is the original filename. If you specify %d as an example, it just tries to convert the filename to decimal.

Maybe a copy replacement exists that would do this, but I have not found it.

You could write a utility and add/replace the to right click menu in file explorer. Then it could do whatever you want.

Rohit Gupta
  • 5,096
0

Python script to prepend the creation date and time to each filename in a folder (tested on Windows 10 Pro 21H2 with Python 3.11.7):

import os
from datetime import datetime

def append_creation_time_to_filenames(folder_path): for filename in os.listdir(folder_path): file_path = os.path.join(folder_path, filename) # Check if it's a file (skip directories) if os.path.isfile(file_path): try: # Get the creation time of the file creation_time = os.path.getctime(file_path) # Convert the timestamp to a datetime object creation_datetime = datetime.fromtimestamp(creation_time) # Format the datetime as a string formatted_datetime = creation_datetime.strftime('%Y-%m-%d_%H-%M-%S') # Split the filename into name and extension name, ext = os.path.splitext(filename) # Create the new filename with the formatted datetime prepended #new_filename = f"{name}{formatted_datetime}{ext}" # to append date to file name new_filename = f"{formatted_datetime}{name}{ext}" # to prepend date to file name new_file_path = os.path.join(folder_path, new_filename)

            # Check if a file with the new filename already exists
            if os.path.exists(new_file_path):
                print(f"Cannot rename '{filename}' to '{new_filename}': file already exists.")
            else:
                # Rename the file
                os.rename(file_path, new_file_path)
                print(f"Renamed '{filename}' to '{new_filename}'")
        except Exception as e:
            print(f"Error processing '{filename}': {e}")


if name == 'main': # Replace '/path/to/your/folder' with the path to the folder you want to process, e.g. "P:\iphone_files\with_stupid_filenames_that_dont_have_date" folder_path = '/path/to/your/folder' append_creation_time_to_filenames(folder_path)

Before:

enter image description here

After:

enter image description here

Change line new_filename = f"{formatted_datetime}_{name}{ext}" if you want to change the datetime format or instead append it.

Franck Dernoncourt
  • 24,246
  • 64
  • 231
  • 400