![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: May 2005
Posts: 3
Rep Power: 0
![]() |
Moving directory trees via .bat files
Hi,
This is a question relating to the DOS shell under W2K. This will sound very trivial, but regardless, I can't figure out how to accomplish it: Via a standard MSDOS .bat script, I need to be able to move the entire contents of one directory to another directory on the same drive with the option to auto-confirm overwrites as needed. Trying to use the MSDOS move command with the /Y option just gives me "access is denied" errors no matter what I do. I can move the contents of one dir into the other dir, but not if a dir of the same name already exists there. My test attempts show I can move these same dirs over one another by drag-and-drop via any file manager, so I'm not sure what the "access is denied" is telling me. If it were a filesharing thing, it would/should give me a problem in a file manager as well. Also, I can't use a copy/delete routine in any event because I tend to move large amounts of files/dirs and that's just far too inefficient. I'd be happy with a pointer a command line util that takes care of this silliness or a basic script routine that emulates the task as defined above. Help will save me lots of hair-pulling and wasted time, so it will be greatly appreciated. ![]() Mansooj |
|
|
|
|
|
#2 |
|
Newbie
Join Date: May 2005
Posts: 3
Rep Power: 0
![]() |
Gosh. And here I was feeling guilty at not being able to come back sooner to thank those who came through with the answers. All this knowledge running about and nothing. Not even a "dump DOS and get yourself a REAL shell!"
I guess not many here are silly or unfortunate enough to still fight with the lameness that is WinDOS. Just to note, I kept mucking about and have a functional workaround that involves mirroring the dir structure of the source dir into the destination dir, then stepping through each level along the way and using MOVE to move the source files from each dir into each new dir, then clearing the empty dir tree from the source location when done. None of that erroneous "access denied" baloney, either. Also found that the MOVE command has a rather short (<128 byte ?) path dir it will take as a parameter. Forced me to have to move files deep in trees first to a temp dir with a basic/root pathname before moving on to the final destination. Good thing CHDIR doesn't have this same limitation or to the same degree. Works perfectly, but it's more file/dir manipulation than is sanely necessary for something so damn basic. Later. Mansooj |
|
|
|
|
|
#3 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Get a real shell.
![]() |
|
|
|
|
|
#4 |
|
Professional Programmer
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 335
Rep Power: 4
![]() |
I was too late getting that one in, then, was I?
Glad the move problem's solved; I clicked my way into this question planning to suggest the MOVE command; WinXP brainfarts are not something I have to worry about. |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Jun 2005
Posts: 2
Rep Power: 0
![]() |
Moving Directories
Try....
xcopy source_dir destination /s/e rd source_dir /s There are loads of extra useful switches on xcopy use - /? to see them If you want more complexity play with the 'for' command using /D |
|
|
|
|
|
#6 |
|
Newbie
Join Date: Jun 2005
Posts: 2
Rep Power: 0
![]() |
BTW - To avoid any prompting this is better...
xcopy mydir destination\mydir /s/e/i rd mydir /s/q Add the full path to mydir if it is not the current directory. |
|
|
|
|
|
#7 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
You're about a month and a half late, mate.
|
|
|
|
|
|
#8 |
|
Programming Guru
![]() |
lol still trying to post everywhere Ooble :p
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity." - Albert Einstein |
|
|
|
|
|
#9 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Why do you think my post count's double yours?
|
|
|
|
|
|
#10 |
|
Programming Guru
![]() |
because you post when at home and i only do it from work?
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity." - Albert Einstein |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|