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.
NOOB needs help
Moderator: DosItHelp
Re: NOOB needs help
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.
-
- Posts: 287
- Joined: 16 Mar 2011 19:17
- Location: scriptingpros.com
- Contact:
Re: NOOB needs help
Why do people on this forum ask themselves questions and then answer them. You can hide your face you can not hide your habits.
-
- Posts: 3
- Joined: 09 Jun 2011 03:10
Re: NOOB needs help
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
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
Re: NOOB needs help
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\"