How to Put Timestamp into File Names?

Do you have a large photo library stored on your computer? Do you have hundreds of thousands of digital photos that are an unorganized mess? Preserving precious life events in your life can be a challenging task, especially if you share photos with your family and friends, and when these tasks are set aside for years until the urgent need to clean, organize and optimize your digital library occurs. In this tutorial, we’ll discuss what are the various ways to put timestamps into file names so that you can easily find them when you need them the most.

Product Spotlight: Easy File Renamer (EFR) — Rename documents, files and folders in bulk easily. EFR is made by our company Sorcim Technologies. It follows Google Software principles. Download it here.

Insert Date-Time into File Names in Region-specific Format

Use the %date% parameter to return the current date and use the %time% parameter to return the current time. Since the predefined %time% parameter returns colons, which are not an acceptable character for file names, you must strip it out. To do so, we’ll tweak the command as follows:

COPY yourfilename.ext file_%time:~0,2%%time:~3,2%%time:~6,2%_%date:~-10,2%%date:~-7,2%%date:~-4,4%.txt

(In the above example, replace yourfilename.ext with the actual name of your file, followed by extension)

Note: Command Prompt will return the date and time in a region-specific format. The date-time format may vary depending on the date-time culture set in your computer’s settings.

Insert Date-Time in Fixed Format

The following command would set the file name in the YYYYMMDD-HHMM format, regardless of the date-time culture set on your PC. 

ren “yourfilename.txt” “somefile-%date:~10,4%%date:~7,2%%date:~4,2%-%time:~0,2%%time:~3,2%.txt”

Using File Explorer

Using File Explorer, you may insert date time into file names in a format of your choice. Keep in mind, File Explorer will add a suffix to your file names with an incremental number (such as =Copy(2), – Copy(3), etc).

Click on the File Explorer icon on your Taskbar.

Open a directory containing the files you want to rename.

Select all the files using Ctrl + A keyboard shortcut.

Press F2 key of your keyboard. On some laptops, you may have to press the Fn + F2 key.

Type a date of your choice. Do not include special characters as they cannot be used in filenames.

Press Enter.

Batch Rename Files with Date-Time Using PowerShell

Windows PowerShell is a command-line utility, much like Command Prompt. You may add date-time in bulk using the command given below:

Get-ChildItem *.png | Foreach { “$($_.DirectoryName)\$($_.BaseName) $(get-date -f yyyy-MM-dd)$($_.extension)”}

Insert Date-Time Using Bat File

Another way to insert current date-time into your file names is to create a Batch (.bat) file.

Click on Start.

Type Notepad and open it from the Search Results.

Enter the following command:

To insert current date:

for /f “tokens=1-5 delims=/ ” %%d in (“%date%”) do rename “filename.txt” %%e-%%f-%%g.txt

To insert current time:

for /f “tokens=1-5 delims=:” %%d in (“%time%”) do rename “filename.txt” %%d-%%e.txt

Click on File, select Save.

Type a name for your file: Rename.bat

Set the File Type to All Files (*.*)

Click on Save.

Using Easy File Renamer

The easiest way to add date-time into your file names is using Easy File Renamer. With Easy File Renamer, you can take advantage of its multiple renaming rules and apply different rules simultaneously.

Features:

  • Add files from multiple folders at once for renaming
  • One-click file renaming
  • New file name preview before renaming your files
  • Batch edit mp3 file tags
  • Easily move or copy files to other directories without errors

Steps

  1. Download, install and open Easy File Renamer.
  2. Click on the Add Files option.
  3. Select the files you wish to add. Click on Open.
  4. To add other directories, follow the same procedure.
  5. In the Rules drop-down box on the left hand side panel of your screen, select the New Name renaming criteria.
  6. Now, enter the current date-time in the textbox. Don’t use any special characters. For example, type 25-July-2021 or simply 25-07-2021.
  7. Click on Add Rules to preview the new file names.
  8. Finally, click on the Rename button to start proceeding.