change file name

December 6, 2010 at 06:09:12
Specs: Windows XP
:: change.bat
@echo off
c:
cd "Power telnet"
cd Spool

:main
for %%F in ("SERVERS*.txt") do call :renamer %%F
goto :eof

:renamer
set old=%1
ren %1 %old:~1,15%
:: end

hi i use this for change files name but when is in file space like
SERVERS-GOLD-SK-ZN22003 - OD Zilina.txt it doesn't catch it. could you pls gave me some advice how to rename these files


See More: change file name

Report •


#1
December 7, 2010 at 05:01:38
use doublequotes while using filenames with space.

Subhash Chandra.


Report •

#2
December 7, 2010 at 06:36:16
hi i used doublequotes but wasn't function. i used it in previously bat file (via example) , but batch still doesnt catch these files and skip they.

second example SERVERS-GOLD-SK-BA21033 - HM Banovce nad Bebravou.txt skiped, but when i updeted it manually to SERVERS-GOLD-SK-BA21033-HMBanovcenadBebravou.txt it take it correct.


Report •

#3
December 7, 2010 at 12:09:19
hi i used doublequotes but wasn't function. i used it in previously bat file (via example) , but batch still doesnt catch these files and skip they.

second example SERVERS-GOLD-SK-BA21033 - HM Banovce nad Bebravou.txt skiped, but when i updeted it manually to SERVERS-GOLD-SK-BA21033-HMBanovcenadBebravou.txt it take it correct.


Report •

Related Solutions

#4
December 7, 2010 at 12:15:44
hi i used doublequotes but wasn't function

Really? Where are they then?

----

Change:

ren %1 %old:~1,15%

To:
ren "%1" "%old:~1,15%"

Can I put a question here?


Report •

#5
December 7, 2010 at 13:16:03
unfortunately still not function

i use like you recomended

@echo off
c:
cd "Power telnet"
cd Spool

:main
for %%F in ("SERVERS*.txt") do call :renamer %%F
goto :eof

:renamer
set old=%1
ren "%1" "%old:~1,15%"
:: end

but is display error message :The system cannot find the file specified.

and files are in

Directory of C:\Power telnet\Spool

07/12/2010 21:59 <DIR> .
07/12/2010 21:59 <DIR> ..
07/12/2010 10:00 2,679,381 report.zip
07/12/2010 08:31 231,718 SERVERS-GOLD-SK-BA21033 - HM Banovce nad Bebravou.txt
07/12/2010 08:32 238,221 SERVERS-GOLD-SK-BB21003 - Báská Bystrica.log
07/12/2010 08:33 232,281 SERVERS-GOLD-SK-BE21030 - Brezno.log
07/12/2010 08:34 238,865 SERVERS-GOLD-SK-BL21004 - BL Petrzalka.log
07/12/2010 08:35 238,606 SERVERS-GOLD-SK-BL21014 - BL Zlaté Piesky.log


Report •

#6
December 7, 2010 at 13:26:43
for /f "tokens=*" %%F in ("SERVERS*.txt") do call :renamer %%F
...

Can I put a question here?


Report •

#7
December 7, 2010 at 13:45:31
is't function now. thx a lot

Report •

#8
December 7, 2010 at 14:16:35
Not a problem, glad you got it sorted out.

Can I put a question here?


Report •


Ask Question