$today = Get-Date -Format “MM/dd/yyyy” # I presume this 20230210
Process each file in a foreach loop
foreach ($file in $filelist) {
## Prepend the datetime string to the file name
if ($file.LastWriteTime.ToString('MM/dd/yyyy') -eq $today) {
$file = $file + $strtoday
}
## Rename the old file to the new name with the datetime string
##Rename-Item "C:\Folder\$file" $newname -Verbose
When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
Just a quick question. Would the script catch or grab all files on that day regardless of the time stamp? I am not sure if I worded that correctly, but let me know.