Page 1 of 1

NOOB needs help

Posted: 09 Jun 2011 03:16
by charlottetat
Hi All.

I'm writing a batch file that will rename a log file to include the date in the filename then move or copy the log file to a network location. So far the rename is going fine although the date is in ddmmyyyy format and I would prefer yyyymmdd format but the file is not moving. Here it is so far (The pause is just there in case the file rename takes a moment):

Set FileDate=%date:/=%
ren c:\batchtests\backup.txt %FileDate%backup.txt
PING 1.1.1.1 -n 1 -w 10000 >NUL
xcopy c:\batchtests\*.txt to "\\servername\x:\!folder\"

Is the ! in the folder name causing problems? Any help is greatly appreciated. :mrgreen:

Re: NOOB needs help

Posted: 09 Jun 2011 03:30
by Ed Dyreen

Code: Select all

xcopy c:\batchtests\*.txt to "\\servername\x:\!folder\"


I believe you first have to assign a networked drive in order to copy to drives on other pc's.

Re: NOOB needs help

Posted: 09 Jun 2011 03:53
by Cleptography
Why do people on this forum ask themselves questions and then answer them. You can hide your face you can not hide your habits. :roll:

Re: NOOB needs help

Posted: 09 Jun 2011 04:47
by charlottetat
Thanks for your help Ed.

To test I edited the batch to try and copy the file to a local location but it's still not moving the file:

Set FileDate=%date:/=%
ren c:\batchtests\backuplog.txt %FileDate%backup.txt
PING 1.1.1.1 -n 1 -w 10000 >NUL
xcopy c:\batchtests\*.txt to c:\batchtests2

Any ideas?

Cleptography - thanks for your, er, input. You are obviously very supportive of those trying to learn a new skill. You also can hide your face but you can not hide the fact you are smart arse with too much time on your hands :roll:

Re: NOOB needs help

Posted: 09 Jun 2011 04:57
by Ed Dyreen

Code: Select all

Set "FileDate=%date:/=%"
ren "c:\batchtests\backuplog.txt" "%FileDate%backup.txt"
PING 1.1.1.1 -n 1 -w 10000 >NUL
xcopy "c:\batchtests\*.txt" "c:\batchtests2\"

Re: NOOB needs help

Posted: 09 Jun 2011 07:28
by charlottetat
Sorted, cheers Ed.