How can I prefix JPG filenames with the EXIF Date Taken in PowerShell?

0
0
Asked By MellowBirch42 On

I have a folder full of JPG files named like IMG_xxxx.jpg and want to rename them as yyyymmdd_IMG_xxxx.jpg. My current command uses LastWriteTime, but that reflects when the files were copied or modified rather than when the photos were taken. How can I read the EXIF Date Taken value and use it in a PowerShell rename command? All files are in the current folder, have Date Taken metadata, and should be renamed in place.

1 Answer

Answered By SlateComet58 On

Changing LastWriteTime to CreationTime won't solve this because both are filesystem timestamps, not the date embedded in the photo's EXIF metadata. CreationTime can also change after files are copied or moved. You need an EXIF reader such as System.Drawing or ExifTool; the property index returned by a shell details API is not automatically available as a PowerShell command named GetDetailsOf.

MellowBirch42 -

I tried CreationTime, but it was also wrong because these files have been copied and moved over the years. The EXIF Date Taken value is the one that remains accurate.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.