Solved

Help rename filename

Posted on 2003-10-31
2
3,766 Views
Last Modified: 2012-06-27
I'm trying to rename SF0310271145.CSV (SFyymmddhhmm.csv) to SISCR12mmddhhmm.csv in command prompt using 'rename' but it truncates the filename.

Here's what I enter at the prompt...

   ren SF03*.CSV SISCR12*.CSV


The result is...

   SISCR1271145.CSV

I tried this in NT4.0 and XP Pro with the same results.  Is there a undocumented switch for 'rename'.  I need to create a batch script that can do this for me automatically.  Please help.  TIA.
0
Comment
Question by:jperri
2 Comments
 
LVL 30

Expert Comment

by:SteveGTR
Comment Utility
Try this:

@echo off

set filename=SF0310271145.CSV

ren %filename% SISCR12%filename:~4%

Good Luck,
Steve
0
 
LVL 5

Accepted Solution

by:
SethHoyt earned 140 total points
Comment Utility
Here's a batch file that will rename all matching files:


@echo off

for %%i in (SF03*.CSV) do (set fname=%%i) & call :rename
goto :eof

:rename
ren %fname% SISCR12%fname:~4%
goto :eof


-Seth
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

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

8 Experts available now in Live!

Get 1:1 Help Now