0

I need to rename all pictures in a folder by adding the very first creation date and time.

I found several examples that allow me to add the creation date, last write date, etc. But I need the date and time the pictures was actually shot, that is the value you can normally see in the "Date" column in windows explorer, that is the column highlighted in the picture (sorry, Italian version of Windows):

enter image description here

The best code I found is the following:

Get-ChildItem -path "./" -recurse -include @("*.jpg") |
rename-item -newname { $_.name  -replace "IMG",($_.CreationDate.toString("yyyyMMddHHmmss"))}

But this will add the creation date, that is the date and time I copied the files to a different folder. What I need instead, as said, is the date and time the pictures was actually shot.

Thanks in advance for your help

Bacon Bits
  • 30,782
  • 5
  • 59
  • 66
s_federici
  • 21
  • 3
  • 1
    Either you [determine the EXIF data of the pictures](https://blogs.technet.microsoft.com/jamesone/2007/07/13/exploring-photographic-exif-data-using-powershell-of-course/) or you will have to go with the `LastWriteTime` of the files. Usually that's the time the file was initially created if you didn't edited it since then. – Olaf Apr 19 '19 at 11:52
  • note that not all pictures have EXIF tags...some people consider that a security risk for example to give too much information – Ctznkane525 Apr 19 '19 at 12:14
  • @Ctznkane525 ... hmmm ... I don't wear my "Tin Foil Hat" at the moment but I assumed that we're talking about his own pictures. ;-) – Olaf Apr 19 '19 at 12:19
  • @Olaf yes, I edited most of the files, but I want to keep them in the order I originally shot the pictures – s_federici Apr 19 '19 at 12:37
  • So you will have to go with the metadata of the files. If I'm not wrong there is no built-in cmdlet or function in Powershell to extract these kind of information. You will have to find some or create one by yourself. Search [PowershellGallery](https://www.powershellgallery.com/packages?q=exif+picture+metadata) - mostly you're not the first one struggling with something. ;-) – Olaf Apr 19 '19 at 12:47
  • I found a quick and perfectly working solution at https://stackoverflow.com/questions/38810203/powershell-rename-file-using-date-taken-attribute. – s_federici Apr 19 '19 at 13:18
  • Cool .... and what did you learn with this? ;-) – Olaf Apr 19 '19 at 13:21
  • @olaf sometimes exif tags are turned off my default and this aren't in the original picture – Ctznkane525 Apr 19 '19 at 14:02
  • @Ctznkane525 ... then he will be out of luck. – Olaf Apr 19 '19 at 14:08

0 Answers0