I have a bunch of .jpg
files spared into different folders with a false timestamp on the filename (1 hour delay) and I want to correct that according to the creation time. The goal of this is to get one CSV sheet containing all the corrected filenames with their full path.
I am now trying to write a PowerShell script that can go through all the folders, extract the creation time and replace it on the filenames with a false timestamp. Below a small example:
Original filename with false timestamp:
Filename, Created Date, Modified Date 20180524010500530_FR785101.jpg, 2018-05-24 00:05:00, 2018-05-24 00:05:34
The correct output would be:
Filename, Created Date, Modified Date 20180524000500530_FR785101.jpg, 2018-05-24 00:05:00, 2018-05-24 00:05:34
I have started to document myself on the use of the CreationTime
command but I still cannot figure out how I can extract the creation time and replace it into the filename timestamp. Also, I don't know how I can make the script run through all the folders and sub-folders containing the image files, to finally export everything into a CSV sheet.
Get-ChildItem -Path "c:/path/to/files/" -Recurse -Include @("*.jpg") |
Rename-Item -NewName {
$_.Name -replace "IMG", ($_.CreationTime.ToString("yyyyMMdd"))
}
UPDATE:
The final .csv
output i would like to get looks like this:
File path, date time, name
path_of_file, Timestamp, Name
C:_users_mind_volume, 20180524000500530, FR785101