Welcome Guest ( Log In | Click here to Register a free account now! )
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.![]() ![]() |
Nov 3 2004, 08:07 PM
Post
#1
|
|
|
Member ![]() ![]() Group: Members Posts: 21 Joined: 30-June 04 Member No.: 1,094 |
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 |
|
|
|
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
|
|
|
|
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 |
|
|
|
![]() ![]() |
| Lo-Fi Version | Time is now: 29th August 2008 - 09:54 PM |