Last active
September 12, 2018 12:14
-
-
Save LiamHz/20d8959cc7e42fbf07b51cda068dfd8a to your computer and use it in GitHub Desktop.
This file contains 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
# Trim ending characters of a filename of every file in a folder | |
Get-ChildItem 'FOLDER_NAME' | rename-item -newname { $_.name.substring(0, $_.name.length-N) } | |
# Trim beginning N characters of a filename of every file in a folder | |
get-childitem *.txt | rename-item -newname { [string]($_.name).substring(N) } | |
# Append a file extension to every file in a folder | |
Get-ChildItem 'FOLDER_NAME' | rename-item -NewName {$_.FullName + ".pdf"} | |
# Append text to every filename BEFORE the file extension | |
Get-ChildItem 'FOLDER_NAME' | % { rename-item –path $_.Fullname –Newname ( $_.basename + (get-date -format 'TEXT_TO_APPEND') + $_.extension) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment