charlespliler
asked on
File Copy Script
I had a question posted earlier about script to copy files and create a text document of the files that were copied:
I need a script to create a folder on a Log Server and then copy files from one Server into that folder. I need it to create a .txt file listing all the files copied but save that file in a different location. Here is the script I'm using now, so if we can just make additions to this it would be great!!!
@echo off
set T=%time:~0,5%
set dir=%date:/=-% %T::=-%
echo The target folder is "%dir%".
xcopy /s /c /y "D:\GCTI\Logs\KSC_SIP_Agen t_1_Bac\Ar chive\*.*" "\\usmoksc5app55\logs\usmo ksc5app10\ %dir%\"
The answer was to add to the existing script:
>> "\\mysharedlocation\mylog. log"
I need a way to make the log file created named for date and time as I will run this script 4 times daily and need to not overwrite any previous logs.
The working answer was to add to the script:
I need a script to create a folder on a Log Server and then copy files from one Server into that folder. I need it to create a .txt file listing all the files copied but save that file in a different location. Here is the script I'm using now, so if we can just make additions to this it would be great!!!
@echo off
set T=%time:~0,5%
set dir=%date:/=-% %T::=-%
echo The target folder is "%dir%".
xcopy /s /c /y "D:\GCTI\Logs\KSC_SIP_Agen
The answer was to add to the existing script:
>> "\\mysharedlocation\mylog.
I need a way to make the log file created named for date and time as I will run this script 4 times daily and need to not overwrite any previous logs.
The working answer was to add to the script:
ASKER
I just need the output log file to be named according to date and time it is created instead of log.log as file name, I need 3/9/11 13:20.log
First off, you cannot use a "/" or ":" in file or folder names...
Second, use the %date:/=-% for the date and the %T::=%
%date:/=-% %T::=%.log
Also, I had an error in the line for your script:
xcopy /L "D:\GCTI\Logs\KSC_SIP_Agen t_1_Bac\Ar chive\*.*" > "\\usmoksc5app55"\\usmoksc 5app55\log s\usmoksc5 app10\%dir %\%date:/= -% %T::=%.log"
Second, use the %date:/=-% for the date and the %T::=%
%date:/=-% %T::=%.log
Also, I had an error in the line for your script:
xcopy /L "D:\GCTI\Logs\KSC_SIP_Agen
ASKER
Here is the script with the correct folder names etc, with the additions you gave me. I get a "network Path not Found error for the log creation but the file copy works just like it used to. Ideas???
@echo off
set T=%time:~0,5%
set dir=%date:/=-% %T::=-%
echo The target folder is "%dir%".
xcopy /L "D:\GCTI\Logs\*.*" > "\\usmoksc5app55"\\usmoksc 5app55\log s\usmoksc5 app20\%dir %\%date:/= -% %T::=%.log"
xcopy /s /c /y "D:\GCTI\Logs\*.*" "\\usmoksc5app55\logs\usmo ksc5app20\ %dir%\"
@echo off
set T=%time:~0,5%
set dir=%date:/=-% %T::=-%
echo The target folder is "%dir%".
xcopy /L "D:\GCTI\Logs\*.*" > "\\usmoksc5app55"\\usmoksc
xcopy /s /c /y "D:\GCTI\Logs\*.*" "\\usmoksc5app55\logs\usmo
Your script is wrong... you have "\\usmoksc5app55 twice
xcopy /L "D:\GCTI\Logs\*.*" > "\\usmoksc5app55"\\usmoksc 5app55\log s\usmoksc5 app20\%dir %\%date:/= -% %T::=%.log"
should be
xcopy /L "D:\GCTI\Logs\*.*" > "\\usmoksc5app55\logs\usmo ksc5app20\ %dir%\%dat e:/=-% %T::=%.log"
should be
xcopy /L "D:\GCTI\Logs\*.*" > "\\usmoksc5app55\logs\usmo
ASKER
I copied it exactly as you posted but it says: The system can not find the path specified
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That was it, no Directory to create the .log in. Thank you so much!!!!
Glad I could help.
You might want to put an "IF NOT EXIST" in front of the "MKDIR ..." for safety reasons. That way if it does exist it won't try to create it but if it doesn't then it will.
IF NOT EXIST "\\usmoksc5app55\logs\usmo ksc5app20\ %dir%" MKDIR "\\usmoksc5app55\logs\usmo ksc5app20\ %dir%"
Just an afterthought.
:)
IF NOT EXIST "\\usmoksc5app55\logs\usmo
Just an afterthought.
:)
Open in new window