Solved

Help rename filename

Posted on 2003-10-31
2
3,850 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
[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 Comments
 
LVL 30

Expert Comment

by:SteveGTR
ID: 9661404
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
ID: 9661445
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

705 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