A friend of mine asked if I could copy files from one folder to another and rename them according to the following format
YYYYMMDDHHMMSS.ext
here source code:
cls
$source="C:\next72\source"
$destination="C:\next72\destination"
set-location $source
$files=get-childitem -Recurse
foreach ($file in $files)
{
if (!$file.PsIsContainer)
{
$newName=$destination+"\"+[string]$file.LastWriteTime.Year +
[string]$file.LastWriteTime.Month +
[string]$file.LastWriteTime.Month +
[string]$file.LastWriteTime.Day +
[string]$file.LastWriteTime.Hour +
[string]$file.LastWriteTime.Minute +
[string]$file.LastWriteTime.Second +
[string]$file.Extension
Copy-Item $file.FullName $newName
}
}
Then change source and destination variable in the script.