Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 5th, 2005, 9:02 PM   #1
Mansooj
Newbie
 
Join Date: May 2005
Posts: 3
Rep Power: 0 Mansooj is on a distinguished road
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
Mansooj is offline   Reply With Quote
Old May 12th, 2005, 9:58 PM   #2
Mansooj
Newbie
 
Join Date: May 2005
Posts: 3
Rep Power: 0 Mansooj is on a distinguished road
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
Mansooj is offline   Reply With Quote
Old May 13th, 2005, 10:50 AM   #3
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Get a real shell.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old May 19th, 2005, 4:41 PM   #4
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 335
Rep Power: 4 mackenga is on a distinguished road
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.
mackenga is offline   Reply With Quote
Old Jun 15th, 2005, 5:27 AM   #5
TonyM
Newbie
 
Join Date: Jun 2005
Posts: 2
Rep Power: 0 TonyM is on a distinguished road
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
TonyM is offline   Reply With Quote
Old Jun 15th, 2005, 6:09 AM   #6
TonyM
Newbie
 
Join Date: Jun 2005
Posts: 2
Rep Power: 0 TonyM is on a distinguished road
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.
TonyM is offline   Reply With Quote
Old Jun 15th, 2005, 7:19 AM   #7
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
You're about a month and a half late, mate.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jun 15th, 2005, 7:26 AM   #8
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
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
Berto is offline   Reply With Quote
Old Jun 15th, 2005, 7:52 AM   #9
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Why do you think my post count's double yours?
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jun 15th, 2005, 9:09 AM   #10
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
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
Berto is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:49 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC