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.
what's wrong with my batch file?
Name: niki chan Date: June 22, 2009 at 02:39:34 Pacific OS: Windows XP CPU/Ram: 3.4 Subcategory: Batch
Comment:
what's wrong with my batch file?
hi there i have a batch file that should search for 3 (or more) files and if found them goto specified command
@echo off setlocal enabledelayedexpansion
for /f "tokens=*" %%A in ('dir /b _344a.jpg;final.jpg;_halph.png') do ( set fileName=%%A if "!fileName!" equ "" (set goto found) ELSE (set goto notfound) :found some commands :notfound some commands )
can you test it please? you can replace those last 4 fines with below lines to see result faster
:found echo> yes.txt :notfound echo> no.txt
why both (txt) file create? i want if files found correct command execute and not both of them. what's wrong? can you fix it or write a new batch file for me please? thanks
Here a batch script that should work. You can't code GOTOs inside a For loop. More it seems you do not understand the basic principles of batch scripting. Study, study, study.
@echo off
for %%j in (344a.jpg final.jpg _halph.png) do (
if exist "%%j" (
echo. %%j found
) else (
echo. %%j NOT found
)
)
0
Response Number 2
Name: niki chan Date: June 22, 2009 at 04:11:15 Pacific
Reply:
thanks but i need goto what should i do?
0
Response Number 3
Name: Razor2.3 Date: June 22, 2009 at 05:34:36 Pacific
Reply:
You cannot mix FOR and GOTO.
Besides, this seems like an overly complicated way around IF EXIST
EDIT: VVV I have no idea what you're talking about, and now I'm confused. VVV
Well, batch scripting is indeed B-programming, but there are B-movies awarded in Hall of Fame as "The Invasion of Body Snatchers". Others are just trash. The script we are talking about belongs to the last category.
Summary: I am updating out DHCP config and wrote this script to get the MAC address of a remote computer on the network. It works fine if I leave the errorlevel part out of it, but I want the errorlevel includ...
Summary: Trying to change the mac address on computers I am building at home. Activate...update ect. Roadrunner will not allow them to connect as my account seems to be tied in with my mac address. smac works...
Summary: Hey all, i'm running into a little problem with my batch file. To explain, i am trying to use the rename command (as well as a few other commands) that produce responses without errorlevels hardcoded ...