Login | |
|
 |
RE: Create Folder with Todays Date then Copy Data to it - 9/20/2007 4:05:55 PM
|
|
 |
|
| |
sheepz
Posts: 247
Score: 2
Joined: 3/17/2006
From: Riverside the 909s
Status: offline
|
unless you didn't post your entire script your missing the first line. this works fine... well at least for me... Const OverWriteFiles = True Source = "C:\test1" Destination = "C:\test2" Set objFSO = CreateObject("Scripting.FileSystemObject") objFSO.CopyFolder Source, Destination, OverWriteFiles
< Message edited by sheepz -- 9/20/2007 4:09:05 PM >
|
|
| |
|
|
|
 |
RE: Create Folder with Todays Date then Copy Data to it - 9/20/2007 11:07:01 PM
|
|
 |
|
| |
svansingel
Posts: 11
Score: 0
Joined: 9/18/2007
Status: offline
|
OK below is the entire script. It does create the folders. The msg box shows the correct path, however the files are not being copied to the folder If you look at the objFSO.CopyFile "\\" &strComputer &"\c$\Documents and Settings\" &strNewComp &"\Local Settings\Application Data\Dictaphone\HSG\Trace\PSClientApp\PSClientApp_LOG.txt", strPSLogsFolder, OverwriteExisting it would copy the files if I put something like C:\FOlderName However since the script above created a new folder with todays date, I need the data to be copied to the new folder. So, in the CopyFile line, I used the StrPsLogsFolder string. I just can not seem to get the data copied to the folder. HELP Thanks in advance. ' VBScript source code Dim strComputer Dim objWMIService Dim objComputer, colComputer Dim thisComp, strNewComp Dim objFSO Dim disFSO, disFolder strComputer = "pacs-wks2" strMonth = Month(Date) If Len(strMonth) = 1 Then strMonth = "0" & strMonth End If strDay = Day(Date) If Len(strDay) = 1 Then strDay = "0" & strDay End If strYear = Year(Date) strCompName = REPLACE(strComputer,"egh-pacs-","") strFolderName = "C:\APACS\" & strCompName & "_" & strMonth & "-" & strDay & "-" & strYear Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.CreateFolder(strFolderName) objFSO.CreateFolder(strFolderName) & "\PSLogs" objFSO.CreateFolder(strFolderName) & "\APIlogs" PSLogsFolder = (strFolderName) & "\PSLogs" APILogsFolder = (strFolderName) & "\APIlogs" msgBox PSLogsFolder msgBox APILogsFolder Call copythisFile() Call copythatFile() Sub copythisFile() on error resume next Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colComputer = objWMIService.ExecQuery _ ("Select * from Win32_ComputerSystem") Const OverwriteExisting = True Set objFSO = CreateObject("Scripting.FileSystemObject") For Each objComputer in colComputer thisComp = objComputer.UserName strNewComp = REPLACE(thisComp,"EGH\","") 'wscript.echo strNewComp datstr = "\\" &strComputer &"\" &"%" &strNewComp &"%" &"\Local Settings\Application Data\Dictaphone\HSG\Trace\PSClientApp\PSClientApp_LOG.txt" 'wscript.echo datstr msgBox strNewComp msgBox PSLogsFolder msgBox APILogsFolder wscript.Sleep 6000 objFSO.CopyFile "\\" &strComputer &"\c$\Documents and Settings\" &strNewComp &"\Local Settings\Application Data\Dictaphone\HSG\Trace\PSClientApp\PSClientApp_LOG.txt", strPSLogsFolder, OverwriteExisting Next End Sub Sub copyThatFile() strPath= "\\" & strComputer & "\c$\ali\site\log" Const OverwriteExisting = True Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(strPath) set colFiles = objFolder.files mytime = Date For Each file in ColFiles on Error resume next thisExt = file.Name If file.datelastmodified >= myTime and Instr(thisExt,"log") Then objFSO.CopyFile File , APILogsFolder , OverwriteExisting 'Else Wscript.Echo "False!" End If Next wscript.echo "Transfer Complete" End Sub Set strComputer = Nothing Set objWMIService = Nothing Set objComputer = Nothing set objFSO = Nothing set disFSO = Nothing
|
|
| |
|
|
|
| |
|
|
 |
|
 |
|
|