View Full Version : DOS commands
Dol Guldur
01-28-2007, 00:24
I am trying to put together a bat file for an installer but it has been years since I used DOS. Does anyone know the command to copy a folder (and all its files/subfolders) to another folder?
md .\bi\ci\
copy .\bi\* .\bi\ci\
del /q .\bi\ci\ci\
del /s /q .\bi\ci\data\world\maps\battle\custom\
del /s /q .\bi\ci\data\world\maps\base\
copy .\fe\* .\bi\ci\
del /s /q .\bi\ci\data\world\maps\campaign\the_south\
pause
The first line works (so I have the right directory path settings!) but the second line results in a "specified file not found" error.
I've tried all manner of variations. It seems to be only looking for files rather than folders I would guess?
Thanks.
EDIT: This is what I am trying to do
1. Install via an installer the modfolder ("ci" in this case) of my mod into a temporary folder
2. execute a bat file which:
i. creates empty modfolder in RTW directory
ii. copies the contents of the bi folder into the new ci folder
iii. copies the ci folder into the bi folder
iv. removes the original ci folder
v. removes the custom and base subfolders from the bi/ci folder
vi. copies the temporary modfolder ("fe") (installed by the installer) into ci
vii. deletes the_south subfolder from the ci folder
Slightly convoluted but a more direct approach resulted in cyclical copying error.
copy *folder to copy* *new folder with the files*
try that.
Dol Guldur
01-28-2007, 00:35
Nope.
I think it might be a command I forgot about: XCOPY
md .\ci\
xcopy .\bi\ .\ci\ /e
xcopy .\ci\ .\bi\ci\ /e
RMDIR /S /Q .\ci\
del /q .\bi\ci\ci\
del /s /q .\bi\ci\data\world\maps\battle\custom\
del /s /q .\bi\ci\data\world\maps\base\
xcopy .\fe\* .\bi\ci\
del /s /q .\bi\ci\data\world\maps\campaign\the_south\
pause
Now lines 1 and 4 work but 2 & 3 are reporting an invalid path which does not make sense if 1 & 4 work. I could not copy the file directly as it reported a cyclical error (probably because I was copying to a subdirectory of it) so I have had to go about it by copying it somewhere else and then copying it again. Gah!
Any dos guys out there?
The obvious suspect on lines 2 & 3 is .\bi. I don't see any reference in the existing batch file to creating such a subdirectory. Where is the .\bi coming from, exactly? Unless the subdirectory \bi already exists in the directory you're running the batch file from, you'll have problems.
Neither lines 1 or 4 would have problems if you're in the incorrect place - it's just removing a directory it created. For example:
Your installer creates C:\mymod\bi
Your batch file runs, but runs from C:\
first line makes C:\ci
second line looks for c:\bi which doesn't exist, so you get invalid path.
third line looks for c:\bi\ci, which also doesn't exist, and you get an error.
fourth line removes C:\ci, which does exist via line one.
Let me guess - your installer creates the \bi subfolder, and you want to create \ci via the batch, not as a subfolder of \bi\, but as a sibling to it. But since your installer puts the batch file in that \bi directory, it's being run from that folder, so
first line: makes a subdirectory in current directory named ci. You're IN bi, so you make bi\ci
second line looks for \bi\bi, which doesn't exist
third line looks for \bi\bi\ci, which also doesn't exist.
fourth line removes bi\ci
Solution: Insert a new line before all others: cd..
Alternative solution: Move the batch file so it's in the same directory as the bi subfolder, instead of being inside the bi subfolder.
that will move you one step up the directory tree, so you'll be where you should be.
Thing to remember here is the . refers to the current directory, which will be wherever your batch file is run from.
Phatose makes a good point, but i'd also question your usage of 'copy .\bi\* - i don't think the asterix is needed (as you want to copy the folder, not the files)
Dol Guldur
01-28-2007, 16:17
The batch file is in the correct place and the bi folder already exists. If ci is created (which it is) then it proves the path correct, an yet on those other lines it is reporting an invalid path.
Very strange.
The asterisk was merely a variation test, along with no asterisk and *.* etc.
You've seen the \ci actually created in the appropriate directory?
Oh wait. I know what the problem is.
Use xcopy .\ci, not .\ci\
Dol Guldur
01-28-2007, 17:59
Yes - the install directory is set in the pathway by the installer itself (for the bat file). ci folder is created correctly.
See above post. The final \ in the xcopy path is the problem - just tested. Must be interpreting that as a subdirectory reference to an unnamed subdirectory.
Dol Guldur
01-28-2007, 19:00
Phatose,
That did it! Gah, I am so rusty!
Big thank you. :2thumbsup:
I can now move on to pinning down the rest of it!
Dol Guldur
02-15-2007, 13:50
Sorry not to update. The code is finished and working and can be found in the Rome directory after installing Forth Eorlingas.
Other mods may adapt to their own needs if credit is given. Oh, and if you improve it then I want to know what you did :)
I do not have time to write a tutorial, but PM me if you have problems. Maybe if I get as big enough response I might write a tutorial...
vBulletin® v3.7.1, Copyright ©2000-2025, Jelsoft Enterprises Ltd.