Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
charlottetat
- Posts: 3
- Joined: 09 Jun 2011 03:10
#1
Post
by charlottetat » 09 Jun 2011 03:16
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.

-
Ed Dyreen
- Expert
- Posts: 1569
- Joined: 16 May 2011 08:21
- Location: Flanders(Belgium)
-
Contact:
#2
Post
by Ed Dyreen » 09 Jun 2011 03:30
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.
-
Cleptography
- Posts: 287
- Joined: 16 Mar 2011 19:17
- Location: scriptingpros.com
-
Contact:
#3
Post
by Cleptography » 09 Jun 2011 03:53
Why do people on this forum ask themselves questions and then answer them. You can hide your face you can not hide your habits.

-
charlottetat
- Posts: 3
- Joined: 09 Jun 2011 03:10
#4
Post
by charlottetat » 09 Jun 2011 04:47
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

-
Ed Dyreen
- Expert
- Posts: 1569
- Joined: 16 May 2011 08:21
- Location: Flanders(Belgium)
-
Contact:
#5
Post
by Ed Dyreen » 09 Jun 2011 04:57
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\"