Reanming Files

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 10 years and 3 days old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
juneb1022
Posts: 34
Last visit: Fri Sep 30, 2016 8:08 am

Reanming Files

Post by juneb1022 »

I'm trying to find a doc or tutorial that explains how to rename files by adding a certain set word + the first 4 characters of that file.

E.G....

12341803.123 will be renamed Diners_1234_12341803.123

or

67891803.456 will be renamed Diners_6789_67891803.456

Any help is appreciated.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Reanming Files

Post by jvierra »

This would be a good place to start: http://www.sapien.com/books/Windows-PowerShell-2
User avatar
juneb1022
Posts: 34
Last visit: Fri Sep 30, 2016 8:08 am

Re: Reanming Files

Post by juneb1022 »

Ok, I'm getting there.. :)


foreach ( $file in $files ) {
$str = Get-ChildItem "$Source\*.*" -Name
$str.Substring(0,4)
}
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Reanming Files

Post by jvierra »

Try
Help rename-item -full
This topic is 10 years and 3 days old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked