New
#1
Simple batch file driving me nuts
All I want to do is check if a folder exists on a network share and if it does, copy a file to it. Should be a piece of cake. Here is my code:
When I run it I get this:Code:@echo on set "newFile=Just a test file.txt" set "hostTarget=\\Kfwserver\HP_D\ShowkeyPlus Data\" if exists "%hostTarget%" copy "%userprofile%\Documents\%newfile%" "%hostTarget%" else echo "%hostTarget%" not found.
If I have just the first two lines all is well, so it's the third line that is causing the problems but I cana't figure out what is wrong.Code:>test C:\Users\ztruk>set "newFile=Just a test file.txt" C:\Users\ztruk>set "hostTarget=\\Kfwserver\HP_D\ShowkeyPlus Data\" "\\Kfwserver\HP_D\ShowkeyPlus Data\" was unexpected at this time. C:\Users\ztruk>if exists "\\Kfwserver\HP_D\ShowkeyPlus Data\" copy "C:\Users\ztruk\Documents\Just a test file.txt" "\\Kfwserver\HP_D\ShowkeyPlus Data\"