Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to be able to rename any file or folder with the current date, so I added the following key value to the registry, to get this option to show up in the right-click context menu:


Cmd.exe /c ren %1 "sample".*

However, I couldn't find how to perform this with the current date. Can anyone help?

share|improve this question
Do you mean you don't know how to retrieve the current date? If so, then the command to do that in Windows is date /t – Indrek Mar 27 '14 at 7:10
Cmd.exe /c ren %1 date /t or date.* these are not working – Mgnfcnt Mar 27 '14 at 7:14
up vote 0 down vote accepted

To get the current date in the Windows command prompt, use the following:

date /t

To rename a file with the current date, you'll need to use the for construct to capture the output of the date command and pass it to ren:

for /f "useback delims=" %x in (`date /t`) do ren %x

Note, however, that the output of date can, depending on your regional settings, contain symbols that cannot be used in a filename, for instance the slash (/). If so, you have two options:

  • Format the date such that it is suitable for use in a filename; see this post at Stack Overflow.

  • Use PowerShell instead. The following should do the trick:

    Rename-Item (Get-Date -Format yyyy-MM-dd)

    That example uses the ISO date format. See Formatting Dates and Times for more information.

To add a new context menu entry to all files, do the following:

  1. Open regedit.exe and navigate to HKEY_CLASSES_ROOT\*\shell

  2. Add a new key and set its name to whatever you want the menu item to be called

  3. Add a new key under that, with the name command

  4. Double-click the (Default) value under the command key and set its value as follows:

    • if using the regular command prompt (note the double percentage signs):

      cmd /c for /f "useback delims=" %%x in (`date /t`) do ren "%1" %%x
    • if using PowerShell:

      cmd /c powershell Rename-Item "%1" (Get-Date -Format yyyy-MM-dd)
share|improve this answer
this is not working. when clicked it opens "OPEN FILE WITH" – Mgnfcnt Mar 27 '14 at 7:27
@Mgnfcnt Please see updated post. I tested both the cmd.exe and PowerShell versions, and both work fine. – Indrek Mar 27 '14 at 8:20
sorry but none of them is working. i am using Windows 7 X64 – Mgnfcnt Mar 27 '14 at 9:17
I tested with Windows 8.1. Looks like you can't invoke PowerShell directly in Windows 7, so I've amended that command slightly (added cmd /c in front). After that, though, both worked just fine for me in Windows 7 as well. Are you sure you're creating the registry key correctly? Right-click on HKEY_CLASSES_ROOT\*\shell, select Export, save it to a file and post the contents of the file (either edit them into your question, or use a site like – Indrek Mar 27 '14 at 9:34 – Mgnfcnt Mar 27 '14 at 9:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.