1.

Solve : 1st time in MSDOS?

Answer»

Hi,
I am LEARNING MSDOS programmimg and my 1st assignment is the FOLLOWING.
1. i have to create a batch file.
2. i have to pass the value "year" in my commandline argument.
3. the batch file should use this argument to replace the name of another file prefixing with the value "Year"
4. the file shud read the content of the file and replace all the corresponding year value with the argument passed.
5. appropriate error message shud be providedwhile passing null, anything other than a 4digit year value.

i tried doing this in parts using the help on net but i am unable to do all of this in a single batch file.
can anyone please suggest how to go about this
?The whole point of assignments is to put into PRACTICE what you have learned in class

We cannot be with you when the exam comes, so at least make an attempt and post what you have tried so far.

If you cannot even start, then maybe you chose the wrong course hi....

thanks for that... but i'm neither taking a course not do i have exams..... i've been asked to learn how to rite batch files as a part of my project.
i know programming in oracle but DOs is much different..... and scripting is totally diffrent.

that is the reason y i asked for help, which could help me understand 1 example to further build on my work files.sorry, I misunderstood your use of the word assignment

post the parts you have and we can try to tie them together No issues at all.

the code is used is the following:

set /p "old=old string ? "
set /p "new=new string ? "

for %%A in (TEST.bat TEST1.bat) do (
>new%%A type nul
)
for /f "tokens=* delims=" %%b in (%%A) do (
set "str=%%b"
>>new%%A echo !str:%old%=%new%!
)
when i ran this batch file.....the system would prompt me to enter the existing value and the new value then the content in TEST.bat and TEST1.bat is replaced with the new value and also 2 new files are created prefixed with 'new'
but somehow no when i run this the system gives me an error could not fine the file specified %a.
i remember changing something... but not sure what.

could you help?

i used the following peice of code to PREFIX the name of the file with a command line argument.

echo %1
set A=%1
ECHO %A%
rename TRIAL.TXT %A%_TRIAL.TXT

now i have to combine the 2 and also generate appropriate error messages.

i have to pass an argument in the command line(2011) and then the file name should be replaced from TRIAL.txt to 2011_TRIAL.txt
also inside the TRIAL.txt file where ever there is the value(2010,yyyy,year,yy) should be replaced with 2011.

if at the command line i pass a null value, non-num, alphanumeric, SPECIAL character... the system to prompt me saying i should enter only a valid 4-digit year value.

hoping that you could help me.
This is homework.

You can tell by the context of the questions.

Try doing some research.



Discussion

No Comment Found