Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Renaming multiple file extensions using Powershell

Posted on 2016-11-29
4
Medium Priority
?
117 Views
Last Modified: 2016-11-29
Heyas,

How do rename all .csv files in a directory to .xls using PowerShell, preserving the filename of course?

I found this command: Get-ChildItem -Filter “*csv*” -Recurse | Rename-Item -NewName {$_.name -replace ‘csv’,’xls’ }

But I want to make sure only the file extension part of the file is changed.

Any assistance is appreciated.

Using powershell v3 on the server.

Thank you
0
Comment
Question by:Zack
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 19

Expert Comment

by:Mal Osborne
ID: 41906714
From a boring old DOS prompt, REN *.csv *.xls will do that. Pretty sure this works in exactly the same way from within Powershell.
0
 

Author Comment

by:Zack
ID: 41906731
Hi Malemsa,

I need a PowerShell version of this I am been tasked with modifying PowerShell job in Task Scheduler.

Thank you.
0
 
LVL 85

Accepted Solution

by:
oBdA earned 2000 total points
ID: 41906793
This is in test mode and will only display what it would do normally. Remove the "-WhatIf" at the end to run it for real.
Get-ChildItem -Filter "*.csv" -Recurse | % {Rename-Item -Path $_.FullName -NewName ($_.BaseName + '.xls') -WhatIf}

Open in new window

0
 

Author Closing Comment

by:Zack
ID: 41906801
Thank you for your help.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question