May 30 2021 08:59 PM
I have a lot of files with name like this "scmp_20200101_123456.jpg" I need to cut short the filename from the second '_' . Can anyone help.
Paul Cheuk.
Jan 29 2022 05:39 AM - edited Jan 29 2022 05:44 AM
If all the files have two underscores, then this command should rename them to the shorter format:
foreach ($file in Get-ChildItem -Path d:\temp -File) {Rename-Item -Path $file.fullname -NewName $file.fullname.split('_')[2]}