Reanming Files

Ask your Windows 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.
Locked
User avatar
juneb1022
Posts: 34
Meble kuchenne na zamówienie - na wymiar - Wrocław
Joined: Mon Jun 10, 2013 10:14 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: 14335
Joined: Tue May 22, 2007 9:57 am
Contact:

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
Joined: Mon Jun 10, 2013 10:14 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: 14335
Joined: Tue May 22, 2007 9:57 am
Contact:

Re: Reanming Files

Post by jvierra »

Try
Help rename-item -full

Locked