Pages

Tuesday, 28 December 2021

Replace file extension

ls C:\Temp\Tesingname\*.* | ? { !$_.PSIsContainer   -and   $_.extension -eq '.txt' } |   ren -NewName { "$($_.BaseName)_$(get-date -format "yyyyMMdd_HHmmss")$($_.extension) "  }  
ls C:\Temp\Tesingname\*.* | ? { !$_.PSIsContainer   -and   $_.extension -eq '.log' } |   ren -NewName { "$($_.BaseName)_$(get-date -format "HHmmss")$($_.extension) "  }  


No comments:

Post a Comment

test

 # Set the file path you want to check $filePath = "C:\Path\To\Your\File.exe" # Check if file exists if (Test-Path $filePath) {   ...

Search This Blog