|
Answer» Hi everyone...
Could anyone help me with a small problem i have...
OK...what i'm after achieving is to simply create a small batch file which copys a named dat file. For example, I would like to copy a file called C:\temp\Paul110.dat to C:\temp\All.dat i can do this manually but thought i'd seek some assistance after trying unsuccessfully to do this in a batch file
What i want my batch file to do is prompt me for a file NUMBER which in this case is 110 and to copy the data to C:\temp\All.dat
All help appreciated.
Thanks, PaulSo you have a lot of files in DIRECTORY C:\temp Paul109.dat, Paul110.dat, Paul111.dat, ...
From time to time, you want to select one such as Paul110.dat and copy it to All.dat, replacing the previous contents of All.dat so that you have two equal files: All.dat and Paul110.dat.
If you don't insist on prompting, you could simply have this
@echo off if x%1==x ( echo You forgot to say what file you wanted to copy goto ADIOS ) if not exist c:\temp\Paul%1.dat ( echo There is no file named Paul%1.dat in c:\temp goto Adios ) copy c:\temp\Paul%1.dat c:\temp\all.dat :Adios
MacEven better ... ASK the user if they forgot Graham
@echo off if x%1==x ( Set /P filenum=You forgot to say what file you wanted to copy: ) else ( Set filenum=%1 ) if not exist c:\temp\Paul%filenum%.dat ( echo There is no file named Paul%filenum%.dat in c:\temp goto Adios ) copy c:\temp\Paul%filenum%.dat c:\temp\all.dat :Adios Quote Set /P filenum
Yeah, Graham - That answers the users "prompt me" need.
I don't use that because Set /P does not work on WindowsNT (in cmd or command or QBasic's funny command)
So I cannot prompt from a BAT file. If I ever have the need, I use a QBasic program (which comes free with WindowsNT, presumably to overcome limitations like that - LOL)
Mac
|