-1

I have folder which have 21 wmv files (01,02 ..21).i have text file which have titles for this wmv files. how do i call the text files and rename the wmv files using powershell. below is the code and there is second link for another powershell code which has similar request as mine but doesn't work for me. let me know if needed more clarity

get-childItem *.wmv | rename-item -newname { $_.name -replace '_',' ' 
-replace '\d{4}', '($0)' }

Windows Powershell - Rename a list of files using a list from a text document

Community
  • 1
  • 1
  • Show sample contents from the text file. Please use a spell checker, the question is hard to parse with all the typos. – vonPryz Dec 23 '13 at 19:55
  • Using punctuation in your question would help people actually understand your question as well. – forgivenson Dec 23 '13 at 20:21
  • the contents of text file are Getting Started with Administration Fundamentals Different Types of cluster hyper-v differnce thanks for the help let me know if you need something – user3130604 Dec 23 '13 at 21:13

1 Answers1

0

Try something like below:

cd <your path>:\<wmv folder name>

ls *.wmv | Foreach -Begin {$i=1} `
   -Process {Rename-Item $_ -NewName ("new_name{0}.wmv" -f $i++) -whatif}
Rahul
  • 76,197
  • 13
  • 71
  • 125