Link to home
Start Free TrialLog in
Avatar of asauce
asauce

asked on

How to copy folders in DOS???

Hello from Barcelona (Catalonia - Spain). First, I only know a little English, so answer with formal words, please (thanks).

I have a .BAT file to copy a folder (with subfolders") from a computer in the local network to my computer, everynight (using XCOPY *.* targetfolder\ /e /y   ). Once the folders are copied (in the target computer)Then, I would like to move, for example the subfolders begining with A, B and C to another folder in the same computer (automatically, using the same .BAT file). Does anybody know the MS-DOS instruction to move the subfolders with their own subfolders (and subfolders' folders........) and files???

I've used XCOPY instruction (and then, DEL), MOVE, etc... but, for example XCOPY A*.* another_target_folder   doesn't work.

Please, help me. Thanks!!!
Avatar of bhoehne
bhoehne

I think xxcopy from http://www.xxcopy.com could be a simple solution to your problem.
xcopy command should work
Avatar of Hanno P.S.
To copy things over use: xcopy /S /E /V   SOURCE TARGET

Where source would be something like
   A:\
   .
   ..\myfolder
   C:\some\folder
etc.
After having copied you can delete the whole folder with
  deltree /y C:\folder
  del /S ..\folder
depending on your DOS version you use.

Please drop an email, as I might be near barcelona some time in near future ;-)
My address is in my profile.
Avatar of asauce

ASKER

OK. Thanks for your answers.
I'll try these''' on friday (now I'm at home [19.16 local time 07.16pm] and tomorrow is our "national day").

Can anybody else out there detect any difference between the available command line switches in xcopy.exe and xcopy32.exe?

I always thought there was a difference that might have been helpful to asauce, but I've just checked again and the /? for both is identical.  Puzzling.
Differences between Xcopy and Xcopy32

Xcopy32.exe is an internal helper program that is not designed to be run directly from the command line. It is designed only

to be run as a helper by the main Xcopy.exe program.

Xcopy32 was introduced with Win95 to deal with long file names,whereas Xcopy can deal,as far as my knowledge goes with only

short file names[8.3 format]
Thanks, SumeetKumar.  That accounts for the partner file XCOPY32.MOD.

asauce, perhaps SumeetKumar's comment might be relevant to you.
Avatar of asauce

ASKER

I've tried now the option said by JUSTUNIX:
xcopy /S /E /V   SOURCE TARGET         executing:

xcopy /s /e /v c:\copy\m*.* d:\copy2            for example.

Then if I have files begining with A, B and M, and folders begining with B and M.... it copies all files begining with M and folders begining with M (good'), but only the files in the subfolder begining with M. I need to "move" all files (a-z) in the folders that begin with M:

c:\copy\map\a*.*
c:\copy\map\b*.*
...
c:\copy\map\m*.*
...
c:\copy\map\z*.*

(I don't know the name of the folder -"map" in the example-)
It only copies the files    c:\copy\map\m*.*    . Do you know what to add to do it?            (do you understand "my English"???)
I continue trying other answers. Thanks.

:(
Avatar of asauce

ASKER

My e-mail is titolaza@hotmail.com, but say something to don't delete your e-mail (If I don't know the "sender", I'll delete the mail -usually commercial mails-).
SOLUTION
Avatar of Hanno P.S.
Hanno P.S.
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am looking for a way that you first create a temporary text file containing the names of the folders, and sort them alphabetically using:

DIR  /ad  /b  /on > folders.txt

Then creating a temporary batch file so that it works its way down through the list changing directory into each, and then executing the xcopy command.

I will get back to you, as I have to go to work now.
Avatar of asauce

ASKER

JUSTUNIX: The "more apropiate" option is to use
xcopy /s /e /v c:\copy-from\m*\*.* d:\copy-to

but the computer says "NO FILE FOUNDED" (translated from Spanish, I don't know the really 'expression' that Windows says).

the option
xcopy /s /e /v c:\copy-from\m*.* d:\copy-to
works, but it only copies the files and folders begining with M, and not all the files in the folders begining with other letter.
:(

for example, if I have the files...

autoexec.bat
mfile.exe
main\autorun.run                          :s
main\mainmain.exe

the first instruction copies the file MFILE.EXE, the folder MAIN and the file in the subfolder MAINMAIN.EXE
it doesn't copy the file AUTOEXEC.BAT (good) but it doesn't copy the file in the subfolder AUTORUN.RUN (in the folder MAIN).

*** The filenames are only an example.




Avatar of asauce

ASKER

BILLDL: I have the file FOLDERS.TXT with the name of the folders, and... what else?
Remember I don't know which is the total number of folders.
asauce

Sorry it has taken me so long, but I have had a lot of work commitments.  This would be so much easier in Windows NT or XP using DOS, but I have been trying this using DOS 7.10 in Win98.

Having created a list of foldernames only, what I was trying to do was something like this:

first create a text file with a single line in it:

set name=

with no space after the = and no extra lines below it.
Call this "setname.txt".

Now create a main batch file that will do something like this:

SET  S=D:\MAPS
rem the S will be a variable for the "source" folder
SET  T=C:\NEWMAPS
rem the T will be a varaible for your destination folder
DELTREE  %T%\
rem first clear any left overs from previous runs
DIR /s b /ad on %S%\ > %T%\folderlist.txt
rem creates alphabetically sorted list of folders from source folder and makes
rem new list file in the target folder to work with
:FOLDERS
rem will use this label to loop back and repeat actions
COPY %T%\setname.txt + %T%\folderlist.txt  %T%\temp.txt>NUL
rem adds the first foldername from folderlist.txt onto the statement
rem from setname.txt to use in a command
TYPE %T%\temp.txt  |  FIND  "setname=" > %T%\temp.bat
rem finds the first line from temp.txt with the statement
rem and gets it ready to run as a command
ECHO  CALL  %T%\makefolders.bat >> %T%\temp.bat
rem the contents of makefolders batch will be given in a minute
TYPE  %T%\temp.txt  |  FIND  /V  "set name=" > %T%\folderlist.txt
rem finds all lines NOT containing string and writes them to folderlist
COPY %T%\folderlist.txt  NUL  |  FIND  "0" > NUL
IF ERRORLEVEL 1 GOTO FOLDERS
rem a way to keep looking through the list looking for the end
rem loops back if there are still more foldernames in the list
:FILES
rem The intention was to now use the same idea as above, but to
rem copy the contents of each folder into the new folders created
rem in the target directory.
rem The above method just isn't working with the batch file called (see below)

Makefolders.bat would be something like this

MD %T%\%name%

Another batch file "copyfiles.bat" would be something like:

COPY /V  (plus a space after it)

I hope you see what I was heading towards, but I haven't really had time to look seriously at where it is going wrong.  There must be an easier way than using lists to work from, but this way SHOULD be accurate if it can be made to run.

I will try and look at this properly on Friday night, if I don't have to work again.
In case you are wondering, I hadn't ignored the fact that you want to split off the FILE names alphabetically into matching folders, but I was going to wait until you had everything in your target directory and use much the same idea and create new foldernames elsewhere using a new list in the same file, and then use FIND to split off the files alphabetically.

Actually, I have just remembered the name of the guy where I originally got this idea from.  I was working from memory there and also some basic notes I made quite a while ago, but I will check out his web pages again.  Maybe you could get some ideas too:

http://www.ericphelps.com/batch/index.htm

In particular:

http://www.ericphelps.com/batch/lines/index.htm
then
http://www.ericphelps.com/batch/lines/frag-man.htm
and
http://www.ericphelps.com/batch/lines/line-uni.htm
and
http://www.ericphelps.com/batch/lists/line-seq.htm
and
http://www.ericphelps.com/batch/secondry/index.htm

Glad I remembered Eric Phelps' name again.  The site is still much the same.

If you have Windows NT or XP, then the FOR statement is really what you need:

http://www.ericphelps.com/batch/charactr/index.htm#for
Avatar of asauce

ASKER

Hello. Please, excuse me for the days I haven't visited it (do you understand "my English"???)  ;) but I have had some work at work  :s   and I think it wasn't possible to do. Now, I'm trying to understand what are you saying (BILLDL) and to do all files you say. I'll try to answer with the results. Thanks, BILLDL!!!
Avatar of asauce

ASKER

I "desist" (don't continue trying) a "technical" method to do this. Now I'm looking for do it in a simple way ("patatero" we say in Spanish -something like "potatoed"-).
I copy all folders in another folder. Having two copies of the same folders, I'm trying to delete folders begining/starting with m, n, o, etc. using RMDIR (deltree command in Windows XP). The problem is that you have to write all the complete name of the folder (you cannot say RMDIR m*.* or RMDIR m*.). Then, I'm trying to make a folderlist (with your method, BILLDL) and use a batch file to delete the folders.
I'll say you my results. Thanks.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is to:

this one hurt my brain any comments about spliting or giveing points?

Please leave any comments here within the next four days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

poobear
EE Cleanup Volunteer
No comment has been added to this question in more than 21 days,
so it is now classified as abandoned.
I will leave the following recommendation for this question in the Cleanup topic area:
points Split [JustUNIX] and [BillDL]
 
Any objections should be posted here in the next 4 days.
After that time, the question will be closed.
Don' accept this post as an awnser!

LordRipper
EE Cleanup Volunteer
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BillDL
Your previous post did help the questioner and I would think that the questioner did see what you were trying to do and this lead into the questioner resolving the problem and this is worth points ;-)

LordRipper
EE Cleanup Volunteer
Thank you, LordRipper and CetusMOD