Solved

Rename files in sub folders

Posted on 2014-03-30
6
806 Views
Last Modified: 2014-03-30
Hello All,

I have a main folder: C:\mainThisCCC

within this main  folder- there are multiple subfolders
Each subfolder has multiple .xlsm files in them

Now how do i do a script or batch script so that it loops through all the files within the subfolders and adds a "_New" to all the file names
0
Comment
Question by:Rayne
  • 3
  • 2
6 Comments
 

Author Comment

by:Rayne
ID: 39965197
so fileA.xlsm is renamed to fileA_New.xlsm

for example..
0
 
LVL 51

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 39965218
Here's a small BAT script that should do the job, it finds all XLSM files under the base directory (including in subfolders), and adds the _NEW to them.

@echo off
set BaseDir=c:\mainThisCCC
for /f "tokens=*" %%A in ('dir /b /a-d /s "%BaseDir%\*.xlsm"') do ren "%%~A" "%%~nA_new%%~xA"

Open in new window

~bp
0
 
LVL 7

Expert Comment

by:Delete
ID: 39965227
Try the below PowerShell script.  It will find all .xlsm files and rename them "Name_NEW.xlsm".  I highly recommend testing first before running it against all of your files.  I also attached the script (change the file extension from .txt to .ps1), which to run you can right click and select "Run with PowerShell".

$Source = "C:\mainThisCCC"
Get-ChildItem -Path $Source -Include *.xlsm -Recurse |ForEach-Object { $_ | Rename-Item -NewName {$_.Basename + "_NEW" + $_.Extension}}

Open in new window

FileRename.txt
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:Rayne
ID: 39965235
Awesome, Bill Awesome
thank you a million :)
0
 
LVL 51

Expert Comment

by:Bill Prew
ID: 39965238
Welcome, glad that helped.

~bp
0
 

Author Comment

by:Rayne
ID: 39965243
Justin,

I apologize, When I awarded the point, I didn't see your comment. And then refreshed the page and saw your comment. Looks it happened at the same time.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Outlook Free & Paid Tools
This video walks the viewer through the process of creating Hyperlinks for the web and other documents. Select the "Insert" tab: Click "Hyperlink":  Type "http://" followed by a web address to reference a website or navigate to a document to ref…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now