Answer» Here is the command I'm trying to make work....
If EXIST \\TECH88\My Documents\Practice\%userdomain% (copy C:\practice\test.txt "\\TECH88\My Documents\Practice\%userdomain%") ELSE MD "\\TECH88\My Documents\Practice\%userdomain%" copy C:\practice\test.txt "\\TECH88\My Documents\Practice\%userdomain%"
My question is... can I double up the commands after ELSE?
I need it to CREATE a directory and copy a file over after that directory is created.
Can I do that together after else? Or do I have to write the first part of the IF statement to check to see if it's created already again.
So how do I do the MD and the COPY both after the ELSE? Or can you not in a simple Batch file?Put the copy command on a seperate line following the IF/ElSE statement.But then it will execute even if the IF statement is true right?
I don't want it to run if it copied once already, know what I mean?
How can I place it on a seperate line but still KEEP it apart of that IF statement?If NOT EXIST \\TECH88\My Documents\Practice\%userdomain% MD "\\TECH88\My Documents\Practice\%userdomain%" copy C:\practice\test.txt "\\TECH88\My Documents\Practice\%userdomain%"
This is only 2 lines (line wrapping in post) with the copy command being line 2. If the target directory does not exist, it will make the directory and then copy the files. If the target does exist, it will fall through to the copy command.Ok thanks great idea! But now I have a new problem....
This doesn't work...
IF NOT EXIST \\TECH88\My Documents\Practice\Silly (copy c:\practice\test.txt "\\TECH88\My Documents\Practice")
The folder Silly does not really exist...
But this won't work... as soon as it sees that that path does not exist on the network it says "The system cannot find the path specified." and then doesn't copy the file.
But this does work...
If NOT EXIST c:\practice\test\text\silly (copy c:\practice\test.txt "\\TECH88\My Documents\Practice")
Here Test\text\silly do not exist, but it copies the test.txt file to the other computer.
So the only difference between the TWO is that one is checking to see if a path EXISTS on the other computer and the other checks to see if a path exists locally.
So for some reason I can't get it to check a bad path on the other computer only locally. Any suggestions?UPDATE>>>>.
Solved that last problem, it works this way...
IF NOT EXIST "\\TECH88\My Documents\Practice\Silly" (copy c:\practice\test.txt "\\TECH88\My Documents\Practice")
All I changed was adding quotation marks around
\\TECH88\My Documents\Practice\Silly
It SEEMS that for some commands it wants quotes, and other times it doesn't care. But that fixed it.
Thanks for your help!
|