How to rename multiple files?

Chloe Jarman 26 Reputation points
2021-02-17T16:36:36.947+00:00

Hi all,

I need to make multiple files in one folder (C:\Users\Desktop\BMS\Siemens Data) change from being the Type of file : File to a Type of file: Text Document (.txt). How do I do that using powershell?

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,427 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Chris 656 Reputation points
    2021-02-17T16:54:26.197+00:00

  2. Chris 656 Reputation points
    2021-02-17T17:14:17.873+00:00

    ren . *.txt

    0 comments No comments

  3. Chris 656 Reputation points
    2021-02-17T17:16:06.133+00:00

    you need two stars, but editor remove my star in my example

    ren star.star star.txt

    0 comments No comments

  4. js2010 186 Reputation points
    2021-02-17T20:54:22.7+00:00

    If I understand you correctly, this is very common. Take off the -whatif if it looks right. Added parentheses so the first part finishes before the second part.

    (get-childitem -file) | rename-item -newname { $_.name + '.txt' } -whatif
    
    What if: Performing the operation "Rename File" on target "Item: C:\users\js\foo Destination: C:\users\js\foo.txt".