|
Answer» Hey all! I've searched far and wide trying to FIND the right commands but i couldnt find the answers so i hope someone can help me!
I want to create a batch file that will copy the contents of 3 directories these files to a new folder and prompt me for the folder name.
Some files from the 3 directories maybe be duplicate so it will prompt replace the existing file so i would need the batch to reply YES to replace the files.
I hope thats enough information! If not let me KNOW.
Any help is much appreciated!To start you on your way, to accept user input, do this
Set /P MyVar=aPromptForTheUser
GrahamGraham has the code for the prompt. The whole thing would be something like: Code: [Select]@echo off set /p dest=Enter the new directory name: xcopy dir1 "%dest%" /y xcopy dir2 "%dest%" /y xcopy dir3 "%dest%" /yIll probs sounds dumb but i can't get it working.. Ive tried making it simple but nothing copies over. This is what ive got in the batch file
@echo off set /p C:\ALLFILES= Enter the new directory name: xcopy dir1 C:\dir /y xcopy dir2 C:\dir2 /y xcopy dir3 C:\dir3 /y
So what i was hoping to do was copy call contents of dir, dir2 and dir3 into a new dir which i would be propted for that will save into C:\ALLFILES.
I have created the directories i wish to copy from and they have files inside them as well as creating the directory C:\ALLFILES\
I have tried with and with out the " . It does however prompt me for a directory name.
What are the exact commands for the process i want to perfom (so i can copy paste it).
Thanks for the help so far guys!Hey guys sorry about the last post.. I think i got it figured out .. i placed the batch file in the directory i wished the new folder to be created and the files to be copied into and it works!! It was creating the folder on my desktop before.. DUH ..
i got this
@echo off set /p dest=Enter the new directory name: xcopy C:\dir "%dest%" /y xcopy C:\dir2 "%dest%" /y xcopy C:\dir3 "%dest%" /y pause
How would i be able to make the batch file executable form say D:\ but create the folder in C:\ALLFILES ? Maybe it would just be easier to leave the batch file in C:\ALLFILES and just create a shortcut on the desktop... lol
Cheers guys!!You should be able to specify C:\ALLFILES at the prompt. That way you can run it from any drive and it should copy to your C: drive.GuruGary it doesnt prompt for the drive. I wanted to make the batch very simple for its users it only prompts for the new folder name where the files from WITHIN the 3 different directories will be copies into
I got it working though looks something like this echo off L: CD L:\directory\ set /p dest=Enter the new directory name: echo Copy process beginning ... xcopy C:\dir "%dest%" /y xcopy C:\dir2 "%dest%" /y xcopy C:\dir3 "%dest%" /y echo copy process COMPLETE, please check output directory .. echo. pause
thanks for the help guys!
|