1.

Solve : batch file to copy a file from one folder and past?

Answer»

Hello,

i am trying to make a batch file which copies a file from a folder in d:/folder1 , checks if a folder name "c:/someFolderName   exists or not in c drive and pastes the file in that folder.
I am NEW to making batch files.
any help?
thank you.it seems to me that you would have to know if the target folder exists, or else what is the sense of what you are doing.

if it does exist,

then  this sort of thing will work for you

copy d:\[filename.ext]  c:\[foldertarget] if the target folder exists then paste the file there otherwise, is there a way to give a warning to CALL administrator ? or just  to tell them that folder DOESNOT exist so that further actions can be taken?it seems that you are the administrator and you need to let the user place files only where they do exist or else how are you going to find them :-/echo off
if exist c:\target\nul: goto cpym
echo Target DIRECTORY does not exist, CTRL-C to ABORT or any key to create
pause
md c:\target
:cpym
xcopy d:\source c:\target /s /e
:end


Note: You can handle the nonexistant directory with just a message and goto end instead of allowing creation of the target directory if you wish, or leave off the /s /e from xcopy if you don't want subdirectories copied, or use copy and a single file name if you just want one file copied...



Discussion

No Comment Found