Computing.Net > Forums > Programming > A problem with batch renaming

A problem with batch renaming

Reply to Message Icon

Original Message
Name: cpuser
Date: December 25, 2006 at 03:56:56 Pacific
Subject: A problem with batch renaming
OS: WinXP PRO
CPU/Ram: doesn`t matter
Model/Manufacturer: doesn`t matter
Comment:

The problem is in the batch renaming.
I have a folder, full of files, which names have to be processed in such a way, that, for example, filename00.txt becomes filename.cd1.txt, etc.
I`ve written a batch script, trying to do that:

@echo off
set RTTT=
for %%A in (*.txt) do (
set RTTT=%%A
ren %RTTT% %RTTT:00=cd1%
echo.
set RTTT=
)

But that is not functioning properly. The problem is, as far as i`ve understood, in "set RTTT=%%A" command, i.e. Windows command processor doesn`t want to set a variable`s value to the value of any for-variable.

If someone knows, hot to solve this problem (or to fullfill the task in the other way) - please write it!


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: December 25, 2006 at 05:26:07 Pacific
Reply: (edit)

I don't get where you're going with naming but to get the var to work as desired:

Try putting in this line [before anything else]:

setLocal EnableDelayedExpansion

Then refer to the var RTTT as !RTTT!


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 2
Name: IVO
Date: December 25, 2006 at 09:07:55 Pacific
Reply: (edit)

Hi M2,

as SAC "Stay alert and Ready to fight" ever and forever... even at Christmas!

Merry Christmas again.

IVO


Report Offensive Follow Up For Removal

Response Number 3
Name: cpuser
Date: December 25, 2006 at 09:40:00 Pacific
Reply: (edit)

That works! Thx!


Report Offensive Follow Up For Removal

Response Number 4
Name: Mechanix2Go
Date: December 26, 2006 at 02:16:14 Pacific
Reply: (edit)

Hi IVO,

Merry Christmas and a great 2007


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: A problem with batch renaming

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge