?
Solved

Help rename filename

Posted on 2003-10-31
2
Medium Priority
?
3,873 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 560 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 August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

764 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