Computing.Net > Forums > Disk Operating System > Rename multiple Files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Rename multiple Files

Reply to Message Icon

Name: Ersen Oyman
Date: November 20, 2003 at 15:58:11 Pacific
OS: WinNT
CPU/Ram: Pentium 2/3 256MB RAM
Comment:

Hi

I need to rename multiple files with a *.xls extension into file names which have a sequential number. E.g.

tony.xls --> 1.xls
paul.xls --> 2.xls
mary.xls --> 3.xls
robert.xls --> 4.xls
.
.
.

I found a solution from an earlier posting which works under winXP but it doesn't work under winNT, original code as follows:-

@echo off
if "%1"=="GoTo" goto %2
%comspec% /v:on /c %0 GoTo start
goto eof


:start
echo This program will sequencially rename all files with .XLS
echo extention from the current directory, which is:
echo %CD%
echo.
echo This process is not reversible.
echo.
set input=


:input
set /P input=Do you wish to continue [Y/N]?
if /I "%input%"=="Y" goto proceed
if /I "%input%"=="N" goto eof
goto input


:proceed
set N=0
for %%F in (*.XLS) do (
set /A N += 1
ren "%%F" !N!%%~xF
)
:eof

Would be greatful if anyone can tell me what to change in the above code to make it work under Windows NT Dos.

Thanks




Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: November 21, 2003 at 02:03:24 Pacific
Reply:

Stated a batch script designed for XP should work fine equally under NT or 2K, being all NT-kernel based environments, I prefer to give you a more straight script to accomplish your job:

@Echo Off
:: RXLS.BAT Syntax: RXls Folder_Name

Echo.
If not exist %~f1.\*.xls (Echo no .xls files found in %~f1 & GoTo :EOF)

Set Count=0
For %%A in (%~f1.\*.xls) Do Call :REN %%A
Set Count=
GoTo :EOF

:REN
Set /A Count=%Count%+1
Ren "%*" %Count%.xls
Echo Ren "%*" %Count%.xls
GoTo :EOF

To run type Rxls Folder_Name, i.e. Rxls C:\MyFolder or, if the folder is the current one, just Rxls . (dot).
Beware the files are renamed in the order they are retrieved in the directory and the process is NOT reversible.



0

Response Number 2
Name: Ersen Oyman
Date: November 22, 2003 at 09:31:58 Pacific
Reply:

I've tried your solution however for some reason it still doesn't work with WinNT. When executed it says file or path not found. Any other ideas?


0

Response Number 3
Name: IVO
Date: November 22, 2003 at 13:50:50 Pacific
Reply:

Sorry, I have tested again carefully my script under either Windows 2000 Professional and Windows XP Home SP1 and it works fine. I run a lot of test games including read only attribute files and folders and no problem stems out. The same expressing folders' name as MyFolder\ and so on... Actually I have no NT environment on hand and after all NT/4.0 should not present a different behavior from 2K/XP.
So... what is happening in your system is out of my knowledge.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Rename multiple Files

Renaming Multiple Files www.computing.net/answers/dos/renaming-multiple-files/13297.html

Renaming multiple files www.computing.net/answers/dos/renaming-multiple-files/15167.html

multiple renaming of file www.computing.net/answers/dos/multiple-renaming-of-file/16829.html