Solved

Help rename filename

Posted on 2003-10-31
2
3,802 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

810 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