Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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 have hundreds of JPG files in a folder. I want to rename each file so that the file name is replaced with "Modified Date/Time" of that file, namely DD.MM.RRRR.HH.MM.jpg. For example,

Before    After  

001.jpg   11.01.2011.16.58.jpg  
002.jpg   12.01.2011.09.32.jpg  
003.jpg   14.01.2011.12.41.jpg  
...       ...

Since colon (:) cannot be used in file names, the colon between HH and MM must be replaced with a period.

I don't want to use a 3rd party tool. Can you provide me with the code to achieve this in Powershell or command line?

share|improve this question
up vote 9 down vote accepted

Try this in Powershell:

Get-ChildItem *.jpg | Rename-Item -newname {$_.LastWriteTime.toString("dd.MM.yyyy.HH.mm") + ".jpg"}
share|improve this answer
1  
Thanks, it works. +1. – Mehper C. Palavuzlar Jan 14 '11 at 13:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .