| 1. |
Solve : Command won't work from notepad .bat file? |
|
Answer» Hello, first post. When I run mybat.bat file the window comes up for a fraction of a second and disappears. This suggests to me that you are running it from Windows Explorer by double clicking. When trouble shooting a batch file that behaves in this way, a good idea is to run it by OPENING a command prompt, changing the current drive and directory as appropriate, and finally typing the batch file name at the prompt. That way if the batch crashes out you just get the prompt back and you can see any error messages. These may give you (and us) an idea of what is happening. In this case, it won't be necessary, as the problem is obvious. Where you use one percent sign in a FOR variable at the prompt, you use TWO of them in a batch file. Thus %i and %j NEED to become %%i and %%j. Quote I've been struggling with this for quite some time. As with most commands, help is available by typing the command at the prompt with the /? switch. Code: [Select]C:\>for /? Runs a specified command for each file in a set of files. FOR %variable IN (set) DO command [command-parameters] %variable Specifies a single letter replaceable parameter. (set) Specifies a set of one or more files. Wildcards may be used. command Specifies the command to carry out for each file. command-parameters Specifies parameters or switches for the specified command. To use the FOR command in a batch program, specify %%variable instead of %variable. Variable names are case sensitive, so %i is different from %I. (That is just the beginning of the very detailed FOR help, which runs to about 4 screens) Perhaps you should get used to using the prompt more. Thank you so MUCH. This fixed the problem. I was beating myself up over this error. Is there anywhere you could point me towards to read up on the little intricacies like this so I can avoid the ANGUISH and having to post a seemingly obvious problem here? Thanks again!Quote from: jinky1087 on May 22, 2009, 11:46:24 PM Is there anywhere you could point me towards to read up on the little intricacies like this Quote from: Me, above As with most commands, help is available by typing the command at the prompt with the /? switch. Or there are plenty of command prompt help sites you can find by using Google. This is one I have bookmarked http://www.ss64.com/nt/ Here's a tip. If you use the CD command with the /D switch, you can change drive and directory at the same time. That is Code: [Select]D: cd Video May be replaced with Code: [Select]cd /d D:\Video |
|