|
Answer» hi everybody,
came on here out of FRUSTRATION trying to write a dos program. i have two problems, the first is that when i run batch files in dos with parameters "%1", it repeats forever. my 2nd problem is that i am trying to write a dos program to copy one files contents to another, temp1.txt to temp2.txt and then delete temp1 and all this using parameters "%1 %2", but it keeps giving me an error of bad syntax, then when i click again it works. does anyone out there have a good knowledge of dos and might be ABLE to help? i have to put the file names to be copied within the program as WELL. thanks in advance if anyone has advice.It would be very helpful if you posted your batch file. Syntax errors range anywhere from not so bad to crash and burn.
Get back to us. this is what i have come up with, i am just a beginner with dos
@echo off @rem temp1 to temp2
PAUSE
echo copy process begins here @COPY %1 %2 @DEL %1 batchfilename temp1.txt temp2.txtI see several errors:
1) Get rid of the @ in front of any REM. All that is is a reminder, and is never printed.
2) You don't really need a PAUSE after the REM. You can have it if you want, though.
3) Get rid of the @ in front of COPY and DEL. This is a MUST.
4) Type REM in front of the last line or delete it. You can use this command for ANY files, and DOS currently thinks it's a command.
Finally, when using this command, be careful to make sure you copy into a directory that exists. If you don't, DOS will think the destination is a file, and will copy to there. This is particularly devastating if you copy multiple files. If I were you, I would add this right before the COPY command:
IF NOT EXIST %2 MD %2
so it looks like this:
IF NOT EXIST %2MD %2 COPY %1 %2 DEL %1
This will create the destination directory ONLY if it doesn't already exist.
Have fun in DOS. Buy a bottle of Tylenol. You'll need it. Thanks Dilbert, i did all that and it really helped out a lot! my only question to you or the rest of the board is if you know if there is a way i can make the batchfile do things automatically. for example, instead of typing (batchfilename temp1.txt temp2.txt) to achieve the desired action, is there a way i can just type the batchfilename only at prompt, but put code in the batch file using parameters %1 %2 and defining those parameters as temp1.txt and temp2.txt in the program as well? any input by Dilbert or anyone else would be great if ya'll get bored.There is no automatic way to do that, as far as I know. I will look into it, and If I find a way, I'll post it up for you. Hello again,
I tried several methods. It seems it COULD be possible, but it would require a way to tell DOS/the BAT file to "remember" the source and destination, then perform the copy and delete. Sadly, that is a little over my head. I don't know how to do that. I do believe it is possible, though. I wish I could help you more. :-/thanks dilbert, you are an absolutely tremendous help with your dos skills. if it helps any i'm not trying to input a destination as both files would be in the same folder, now all i have to do is figure out a way to connect the parameters with the filenames. i'm learning more about dos than i ever thought possible lolHello again,
You don't need to tell DOS: "Okay, %1 is THIS file, and %2 is this OTHER file." DOS is just barely smart enough to do that for you. So, if your .BAT filename is MOVE, while in the prompt, you could type
MOVE temp1.TXT temp2.TXT
and DOS will connect the dots. You could also type, for example:
MOVE temp1.TXT C:\Documents\temp2.TXT
And (if you followed my extra optional instruction) it will copy to C:\Documents and copy to temp2.TXT. Because of the IF NOT line, this folder would be created to accommodate the copy command. (You don't HAVE to copy to another directory, but that line is useful for if you ever do.) The IF NOT EXIST %2 MD %2 line tells DOS the following:
If the destination folder doesn't exist, (IF NOT EXIST)make directory (MD) specified in the command.
Well, that should help you out. Best of luck on your next project.
(By the way, did you take my advice on the Tylenol? DOS gives you lots of headaches, since it happily tells you that you messed up, and offers no help on fixing it.) lol Dilbert,
gonna buy some tylenol right now. thanks for your help explain parameters and what i should do etc. please ignore the other question i asked you on your other post cause i think it is falling into place now. where do i send the money for your amazingly creative dos services lolPlease don't send me money. I'd never be able to explain it to my relatives. I need Help, I'm trying to run this game called Serf City on my computer and I need to do so through DOSBox. When I go and run the file it says that I have a "memory Allocation Failure" and that the application needs the file "spae.pa." I have read (correct me if I'm wrong) that this may also be called a block and I may need some kind of "if" statement. How Do I go about doing this, and If you know can u explain it to me in "dumbed down" terms.....
Here is some info that may help: I'm using Windows NT, 634 KB of free conventional Memory, 23KB of free memory in 1 upper block (Largest UMB 23KB) 15 280 kb in free and extended and free expanded memory
Thanks! Jenny
|