Ringtones | Personal Loans | Loans | Payday Loan | Bunbury
Help creating batch file [Archive] - PCMech Forums

PDA

View Full Version : Help creating batch file


neillsmob
05-26-2003, 03:03 PM
I have this question that I'm not that sure of, I think I now the answer but again not sure.Here we go...
A user wants a batch file which copies all of their files from the C:\FINANCE and C:\DOCUMENTS directories onto a floppy disk and then lists the contents of the floppy disk.Write a batch file to do this. And my answer to the question is....

@ echo off
C:
cd\
copy C:\Finance\*.*A:
copy C:\Documents\*.*A:
cd\
cls
dir A:
hope I have wrote it out write. Thx for any response :)

reboot
05-26-2003, 03:47 PM
That works, a couple of redundant lines.
If you want it automated, you need to add a bit though, and be careful of spaces, and using wildcards.
I would do it thus:

@echo off
cd\
a:
md Finance
md Documents
copy c:\finance\*.* a:\finance\*.*
copy c:\documents\*.* a:\finance\*.*
echo hit any key to list the contents of a:\finance
pause
cd a:\finanace
dir |more
echo hit any key to list the contents of a:\documents
pause
cd a:\documents
dir |more
echo hit any key to exit
pause
echo you may now close this window
end

TwoRails
05-26-2003, 05:08 PM
The "|Y" (pipe Y) should be a "/Y" (forward slash Y).

neillsmob
05-26-2003, 05:09 PM
thx m8, so thats 2 examples to make the batch file.thats back to you reboot.

reboot
05-26-2003, 05:16 PM
If I remember my DOS commands, the "/y" can be used within a statement, whereas the "|y" is used at the end.
To use /y in the example above, the line would read:
copy /y c:\finance\*.* a:\finance\*.*
Which is totally redundant anyhow, because of my failing memory, the copy command doesn't require a confirmation!
(I was thinking xcopy, not just copy...)
Edited above .bat example to reflect this...