Computer Help and Spyware Removal Computer Help and Spyware Removal Computer Help and Spyware Removal Computer Help Forums Windows Startup Programs Database Spyware and Malware Removal Guides Computer Tutorials Uninstall Database File Database Computer Glossary Computer Resources
 

Welcome Guest ( Log In | Click here to Register a free account now! )



Register a free account to unlock additional features at BleepingComputer.com
Welcome to Bleeping Computer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.
Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

 
Reply to this topicStart new topic
> Renaming File Sequentially Using Dos Script, Batch file
Qwerty0907
post Nov 3 2004, 08:07 PM
Post #1


Member
**

Group: Members
Posts: 21
Joined: 30-June 04
Member No.: 1,094



Hi All,


Are there any books or websites that teach people how to write batch files?

I was playing with batch code I found on www.computing.net and the stupidest thing happen. I renamed Old1.jpg to File01.jpg, and can do that till I hit 09.

When I try that, instead of File09.jpg, it goes balistic and name it as File008.jpg. The more file I have the more leading 0's it adds.

Here is my code:

@echo off
set Count=00
dir /b | findstr "[0-9].jpg" > tmp1.txt
sort tmp1.txt > tmp2.txt
for /f %%a in (tmp2.txt) do (call :incr
call :ReNumber %%a %%Count%%)
erase tmp?.txt *.tmp
exit /b
:incr
set /a Count=%Count%+1
if %count% LSS 10 set Count=00%count%
goto :eof
:ReNumber %1 %2
if exist %1 ( rem echo renamed %1 File%2.jpg
ren %1 %1.tmp
ren %1.tmp File%2.jpg) else (rem echo ren renamed %1
File%2.jpg
ren %1 File%2.jpg)
goto :eof

And here is the Error:
renamed Old1.jpg File01.jpg
renamed Old2.jpg File02.jpg
renamed Old3.jpg File03.jpg
renamed Old4.jpg File04.jpg
renamed Old5.jpg File05.jpg
renamed Old6.jpg File06.jpg
renamed Old7.jpg File07.jpg
renamed Old8.jpg File08.jpg
Invalid number. Numeric constants are either decimal (17),
hexadecimal (0x11), or octal (021).
renamed Old9.jpg File008.jpg

Thank you in advance for any help
Go to the top of the page
 
+Quote Post
Grinler
post Nov 3 2004, 11:31 PM
Post #2


Bleep Bleep!
******

Group: Admin
Posts: 28,405
Joined: 24-January 04
From: USA
Member No.: 3



The best site for information on batch files is by far the following one:

http://www.robvanderwoude.com/index.html


--------------------
Lawrence
Go to the top of the page
 
+Quote Post
penmore
post Nov 5 2004, 03:17 AM
Post #3


Malware Sniffer
*****

Group: HJT Team
Posts: 757
Joined: 4-September 04
From: West Coast of Scotland
Member No.: 2,438



Hi Qwerty0907,

If you didn't find the answer to your Numeric constants are either decimal... question then post back and I'll try and explain.

Peter smile.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 29th August 2008 - 09:54 PM


Advertise   |   About Us   |   Terms of Use   |   Privacy Policy   |   Contact Us   |   Site Map   |   Chat   |   Tutorials   |   Uninstall List
Discussion Forums   |   The Computer Glossary   |   Resources   |   RSS Feeds   |   Startups   |   The File Database   |   Malware Removal Guides

© 2003-2008 All Rights Reserved Bleeping Computer LLC.