I want to add 3 characters eg "-94" to the end of a file name to all of the files in a wordperfect directory. There are many directories with different years and I will be doing the same with each year e.g NanSloan.wpd would be changed to NanSloan-94.wpd (as well as all of the other files in the 1994 directory. I would like to use Powershell to do this

  • 2
    This shouldn't be too hard, so I'll give you general guidance - try something first and repost when you have a specific question and youv'e tried google. You're going to use the Get-ChildItem command on the directory, and for each item within the directory use a where clause to select just the .wpf files, and within the properties of the files you'll have everything you need - the original name, the parent dir name, and the extension. Use move-item to rename it. – Chris N Apr 21 '16 at 13:49

Try the following

Get-ChildItem -Filter "*wpd" | rename-item -NewName {$_.name-replace '.wpd','-94.wpd'}

Edit: You can add the -Recurse parameter to apply to subfolders


  • thank you Z. When I tried the above solution, Powershell just hung. – user-marl494 Apr 29 '16 at 11:34
  • I tried PS C:\WPDOCS-aa\0000-wpdocs 2015> Get-ChildItem -Path "C:\WPDOCS-aa\0000-wpdocs 2015" -Filter "wpd" -Recurse | rename-item -NewName {"$($_.BaseName) -2015.wpd"} PS C:\WPDOCS-aa\0000-wpdocs 2015> – user-marl494 Apr 29 '16 at 11:35
  • this seemed to run (v 5 with Windows 10 Pro) but there were no file changes. I also tried this without the path, being I had changed directories already to where I was going to rename. – user-marl494 Apr 29 '16 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.