Last active
August 29, 2015 14:08
-
-
Save ytechie/a41593592b63d98cdae1 to your computer and use it in GitHub Desktop.
Powershell Script to remove partial file name before the tilde
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I had some files that had some garbage text attached and separated with a tilde. This script was used to remove that extra text. | |
# Example: blah ~ IMG123.jpg -> IMG123.jpg | |
Get-ChildItem "e:\photography" -Recurse -filter *~* | ` | |
Foreach-Object { | |
$oldName = $_.Name | |
$pos = $oldName.IndexOf("~") | |
$newName = $oldName.Substring($pos + 2) | |
#write-host $_.fullname | |
write-host $_.FullName + " -> " + $newName | |
rename-item $_.FullName -NewName $newName | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment