Prev: BUY FAKE PASSPORTS OF CANADA,FAKE CANADIAN PASSPORTS FOR SALE! FAK
Next: Specify open file with Excel 2007
From: Sear S on 31 May 2010 09:43 Hi Tom, Thanks again! However I just wanted to point out that the filenames could be different on some servers but will all have the same extension can I use something like *.log? Also, I tried this argument and it didn;pt work as well as the first one sServerNameFile = "\\to8pal01\express\Sam\WSnames.txt" sLogName1 = "ipc_err0.elg" sLogName2 = "ipc_err1.elg" sLogName3 = "ipc_err2.elg" sDestination = "\\to8pal01\express\Sam\Logs\" with createobject("scripting.filesystemobject") sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll for each server in split(sServerNames, vbNewLine) sLogPath = "\\" & server & "\C$\" & sLogName Select Case True case .fileExists(sLogPath1) .copyfile slogpath, sDestination & server & sLogName1 case .fileExists(sLogPath2) .copyfile slogpath, sDestination & server & sLogName2 case .fileExists(sLogPath3) .copyfile slogpath, sDestination & server & sLogName3 end if "Tom Lavedas" wrote: > On May 28, 10:30 am, Sear S <Se...(a)discussions.microsoft.com> wrote: > > HI Tom, > > > > A BIG THANK YOu this works perfectly!! > > If the file name on some servers is different than the one mentioned in the > > Slogname section then can I add more file names as below? > > > > sServerNameFile = "c:\some\local\folder\Servernames.txt" > > > > > sLogName = "logfilename,logfilename2, etc..." > > > sDestination = "\\Storageservername\locationfoldername\" > > > with createobject("scripting.filesystemobject") > > > sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll > > > for each server in split(sServerNames, vbNewLine) > > > sLogPath = "\\" & server & "\C$\" & sLogName > > > if .fileExists(sLogPath) then > > > .copyfile slogpath, sDestination & server & "_" & sLogName > > > end if > > > next > > > end with > > "Tom Lavedas" wrote: > > > On May 27, 3:57 pm, Sear S <Se...(a)discussions.microsoft.com> wrote: > > > > Hi Tom, > > > > > > Ok let me explain in details what I exactly want to accomplish: > > > > > > I need a script that I can use to gather a log file from a number of > > > > workstations...in total 40 workstations > > > > The log file is located on C:\logfilename of each one of those workstations... > > > > I have full admin access to those PCs therefore permissions won't be an issue! > > > > Once I ran the script, I would like it to copy all those log files from > > > > those machines and put them somewhere on a shared drive for me... > > > > I hope that clarifies a little bit my point > > > > > > Thanks > > > > > > Sam > > > > > OK, from what you said, you just need to change the value of sLogName > > > to be "logfilename" and the sDestination content to be "\ > > > \Storageservername\locationfoldername\" and complete the list of > > > server names. > > > > > sServerNames = "server1,server2,server3,etc" > > > sLogName = "logfilename" > > > sDestination = "\\Storageservername\locationfoldername\" > > > with createobject("scripting.filesystemobject") > > > for each server in split(sServerNames, ",") > > > sLogPath = "\\" & server & "\C$\" & sLogName > > > if .fileExists(sLogPath) then > > > .copyfile slogpath, sDestination & server & sLogName > > > end if > > > next > > > end with > > > > > Of course, 40 server names would be a problem in the SET statement, so > > > a file list (one name per line) would be better, something like > > > this ... > > > > > sServerNameFile = "c:\some\local\folder\Servernames.txt" > > > sLogName = "logfilename" > > > sDestination = "\\Storageservername\locationfoldername\" > > > with createobject("scripting.filesystemobject") > > > sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll > > > for each server in split(sServerNames, vbNewLine) > > > sLogPath = "\\" & server & "\C$\" & sLogName > > > if .fileExists(sLogPath) then > > > .copyfile slogpath, sDestination & server & "_" & sLogName > > > end if > > > next > > > end with > > > > > It should create one file for each server in the specified location. > > > _____________________ > > > Tom Lavedas > > > . > > If there are just a few differences, that could be handled as Select > Case in place of the simpler "IF .FileExists(...)" statement, > something like this ... > > Select Case True > case .fileExists(sLogPath1) > .copyfile slogpath, sDestination & server & sLogName1 > case .fileExists(sLogPath2) > .copyfile slogpath, sDestination & server & sLogName2 > case .fileExists(sLogPath3) > .copyfile slogpath, sDestination & server & sLogName3 > end if > > Of course, the three file name variables would need to be defined > earlier in the script. > > If there are many different names, it might be easier to add them as > part of the ServerNames text file, on lofgilename per server, as > in ... > > server1, logfilename.log > server2 anothername.txt > server3 > etc. > > To simplify things a bit, a blank for the name could be used to > indicate the use of a default name. Then the code might look like > this ... > > sServerNameFile = "c:\some\local\folder\Servernames.txt" > sDefaultLogName = "logfilename" > sDestination = "\\Storageservername\locationfoldername\" > with createobject("scripting.filesystemobject") > sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll > for each sLine in split(sServerNames, vbNewLine) > sLine = trim(sLine) > if not (sLine) = "" then > aTemp = split(sLine & " " & sDefaultLogName) > server = aTemp(0) > sLogName = aTemp(1) > sLogPath = "\\" & server & "\C$\" & sLogName > if .fileExists(sLogPath) then > .copyfile slogpath, sDestination & server & "_" & sLogName > end if > end if > next > end with > _____________________ > Tom Lavedas > . >
From: Tom Lavedas on 31 May 2010 13:05 On May 31, 9:43 am, Sear S <Se...(a)discussions.microsoft.com> wrote: > Hi Tom, > > Thanks again! > However I just wanted to point out that the filenames could be different on > some servers but will all have the same extension > can I use something like *.log? > Also, I tried this argument and it didn;pt work as well as the first one > > sServerNameFile = "\\to8pal01\express\Sam\WSnames.txt" > sLogName1 = "ipc_err0.elg" > sLogName2 = "ipc_err1.elg" > sLogName3 = "ipc_err2.elg" > sDestination = "\\to8pal01\express\Sam\Logs\" > with createobject("scripting.filesystemobject") > sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll > for each server in split(sServerNames, vbNewLine) > sLogPath = "\\" & server & "\C$\" & sLogName > Select Case True > case .fileExists(sLogPath1) > .copyfile slogpath, sDestination & server & sLogName1 > case .fileExists(sLogPath2) > .copyfile slogpath, sDestination & server & sLogName2 > case .fileExists(sLogPath3) > .copyfile slogpath, sDestination & server & sLogName3 > end if > > "Tom Lavedas" wrote: > > On May 28, 10:30 am, Sear S <Se...(a)discussions.microsoft.com> wrote: > > > HI Tom, > > > > A BIG THANK YOu this works perfectly!! > > > If the file name on some servers is different than the one mentioned in the > > > Slogname section then can I add more file names as below? > > > > sServerNameFile = "c:\some\local\folder\Servernames.txt" > > > > > sLogName = "logfilename,logfilename2, etc..." > > > > sDestination = "\\Storageservername\locationfoldername\" > > > > with createobject("scripting.filesystemobject") > > > > sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll > > > > for each server in split(sServerNames, vbNewLine) > > > > sLogPath = "\\" & server & "\C$\" & sLogName > > > > if .fileExists(sLogPath) then > > > > .copyfile slogpath, sDestination & server & "_" & sLogName > > > > end if > > > > next > > > > end with > > > "Tom Lavedas" wrote: > > > > On May 27, 3:57 pm, Sear S <Se...(a)discussions.microsoft.com> wrote: > > > > > Hi Tom, > > > > > > Ok let me explain in details what I exactly want to accomplish: > > > > > > I need a script that I can use to gather a log file from a number of > > > > > workstations...in total 40 workstations > > > > > The log file is located on C:\logfilename of each one of those workstations... > > > > > I have full admin access to those PCs therefore permissions won't be an issue! > > > > > Once I ran the script, I would like it to copy all those log files from > > > > > those machines and put them somewhere on a shared drive for me... > > > > > I hope that clarifies a little bit my point > > > > > > Thanks > > > > > > Sam > > > > > OK, from what you said, you just need to change the value of sLogName > > > > to be "logfilename" and the sDestination content to be "\ > > > > \Storageservername\locationfoldername\" and complete the list of > > > > server names. > > > > > sServerNames = "server1,server2,server3,etc" > > > > sLogName = "logfilename" > > > > sDestination = "\\Storageservername\locationfoldername\" > > > > with createobject("scripting.filesystemobject") > > > > for each server in split(sServerNames, ",") > > > > sLogPath = "\\" & server & "\C$\" & sLogName > > > > if .fileExists(sLogPath) then > > > > .copyfile slogpath, sDestination & server & sLogName > > > > end if > > > > next > > > > end with > > > > > Of course, 40 server names would be a problem in the SET statement, so > > > > a file list (one name per line) would be better, something like > > > > this ... > > > > > sServerNameFile = "c:\some\local\folder\Servernames.txt" > > > > sLogName = "logfilename" > > > > sDestination = "\\Storageservername\locationfoldername\" > > > > with createobject("scripting.filesystemobject") > > > > sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll > > > > for each server in split(sServerNames, vbNewLine) > > > > sLogPath = "\\" & server & "\C$\" & sLogName > > > > if .fileExists(sLogPath) then > > > > .copyfile slogpath, sDestination & server & "_" & sLogName > > > > end if > > > > next > > > > end with > > > > > It should create one file for each server in the specified location.. > > > > _____________________ > > > > Tom Lavedas > > > > . > > > If there are just a few differences, that could be handled as Select > > Case in place of the simpler "IF .FileExists(...)" statement, > > something like this ... > > > Select Case True > > case .fileExists(sLogPath1) > > .copyfile slogpath, sDestination & server & sLogName1 > > case .fileExists(sLogPath2) > > .copyfile slogpath, sDestination & server & sLogName2 > > case .fileExists(sLogPath3) > > .copyfile slogpath, sDestination & server & sLogName3 > > end if > > > Of course, the three file name variables would need to be defined > > earlier in the script. > > > If there are many different names, it might be easier to add them as > > part of the ServerNames text file, on lofgilename per server, as > > in ... > > > server1, logfilename.log > > server2 anothername.txt > > server3 > > etc. > > > To simplify things a bit, a blank for the name could be used to > > indicate the use of a default name. Then the code might look like > > this ... > > > sServerNameFile = "c:\some\local\folder\Servernames.txt" > > sDefaultLogName = "logfilename" > > sDestination = "\\Storageservername\locationfoldername\" > > with createobject("scripting.filesystemobject") > > sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll > > for each sLine in split(sServerNames, vbNewLine) > > sLine = trim(sLine) > > if not (sLine) = "" then > > aTemp = split(sLine & " " & sDefaultLogName) > > server = aTemp(0) > > sLogName = aTemp(1) > > sLogPath = "\\" & server & "\C$\" & sLogName > > if .fileExists(sLogPath) then > > .copyfile slogpath, sDestination & server & "_" & sLogName > > end if > > end if > > next > > end with > > _____________________ > > Tom Lavedas > > . There was a logic error, sorry. sServerNameFile = "\\to8pal01\express\Sam\WSnames.txt" sLogName1 = "ipc_err0.elg" sLogName2 = "ipc_err1.elg" sLogName3 = "ipc_err2.elg" sDestination = "\\to8pal01\express\Sam\Logs\" with createobject("scripting.filesystemobject") sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll for each server in split(sServerNames, vbNewLine) Select Case True case .fileExists(sLogPath1) sLogPath = "\\" & server & "\C$\" & sLogName1 .copyfile slogpath, sDestination & server & sLogName1 case .fileExists(sLogPath2) sLogPath = "\\" & server & "\C$\" & sLogName2 .copyfile slogpath, sDestination & server & sLogName2 case .fileExists(sLogPath3) sLogPath = "\\" & server & "\C$\" & sLogName3 .copyfile slogpath, sDestination & server & sLogName3 end if There is no provision for a wildcard for the ForExists() function, though there is one for the copy file. But the destination file name would need to be the same as the source name. The procedure won't work, because it would probably end up overwritting prvious files of the same name. A new approach is possible, but it would need to preform a file by file search to find the right one. That's a little beyond my interest. _____________ Tom Lavedas
From: Al Dunbar on 31 May 2010 22:30 "Sear S" <SearS(a)discussions.microsoft.com> wrote in message news:22ADA6AD-3CD7-4481-83CF-97BCF68E3C65(a)microsoft.com... > Hi Tom, > > Thanks again! > However I just wanted to point out that the filenames could be different > on > some servers but will all have the same extension > can I use something like *.log? > Also, I tried this argument and it didn;pt work as well as the first one > > sServerNameFile = "\\to8pal01\express\Sam\WSnames.txt" > sLogName1 = "ipc_err0.elg" > sLogName2 = "ipc_err1.elg" > sLogName3 = "ipc_err2.elg" > sDestination = "\\to8pal01\express\Sam\Logs\" > with createobject("scripting.filesystemobject") > sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll > for each server in split(sServerNames, vbNewLine) > sLogPath = "\\" & server & "\C$\" & sLogName > Select Case True > case .fileExists(sLogPath1) > .copyfile slogpath, sDestination & server & sLogName1 > case .fileExists(sLogPath2) > .copyfile slogpath, sDestination & server & sLogName2 > case .fileExists(sLogPath3) > .copyfile slogpath, sDestination & server & sLogName3 > end if I haven't followed this thread in great detail, however, the change from if fileexists to a case structure makes me wonder if a detail has been missed. Each time through the select case structure above will copy at most only one file. If all three of the files exist, the only one copied will be "ipc_err0.elg". If it is desired to process all those that exist, you will need an if fileexists then copy endif block for each one. /Al > "Tom Lavedas" wrote: > >> On May 28, 10:30 am, Sear S <Se...(a)discussions.microsoft.com> wrote: >> > HI Tom, >> > >> > A BIG THANK YOu this works perfectly!! >> > If the file name on some servers is different than the one mentioned in >> > the >> > Slogname section then can I add more file names as below? >> > >> > sServerNameFile = "c:\some\local\folder\Servernames.txt" >> > >> > > sLogName = "logfilename,logfilename2, etc..." >> > > sDestination = "\\Storageservername\locationfoldername\" >> > > with createobject("scripting.filesystemobject") >> > > sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll >> > > for each server in split(sServerNames, vbNewLine) >> > > sLogPath = "\\" & server & "\C$\" & sLogName >> > > if .fileExists(sLogPath) then >> > > .copyfile slogpath, sDestination & server & "_" & sLogName >> > > end if >> > > next >> > > end with >> > "Tom Lavedas" wrote: >> > > On May 27, 3:57 pm, Sear S <Se...(a)discussions.microsoft.com> wrote: >> > > > Hi Tom, >> > >> > > > Ok let me explain in details what I exactly want to accomplish: >> > >> > > > I need a script that I can use to gather a log file from a number >> > > > of >> > > > workstations...in total 40 workstations >> > > > The log file is located on C:\logfilename of each one of those >> > > > workstations... >> > > > I have full admin access to those PCs therefore permissions won't >> > > > be an issue! >> > > > Once I ran the script, I would like it to copy all those log files >> > > > from >> > > > those machines and put them somewhere on a shared drive for me... >> > > > I hope that clarifies a little bit my point >> > >> > > > Thanks >> > >> > > > Sam >> > >> > > OK, from what you said, you just need to change the value of sLogName >> > > to be "logfilename" and the sDestination content to be "\ >> > > \Storageservername\locationfoldername\" and complete the list of >> > > server names. >> > >> > > sServerNames = "server1,server2,server3,etc" >> > > sLogName = "logfilename" >> > > sDestination = "\\Storageservername\locationfoldername\" >> > > with createobject("scripting.filesystemobject") >> > > for each server in split(sServerNames, ",") >> > > sLogPath = "\\" & server & "\C$\" & sLogName >> > > if .fileExists(sLogPath) then >> > > .copyfile slogpath, sDestination & server & sLogName >> > > end if >> > > next >> > > end with >> > >> > > Of course, 40 server names would be a problem in the SET statement, >> > > so >> > > a file list (one name per line) would be better, something like >> > > this ... >> > >> > > sServerNameFile = "c:\some\local\folder\Servernames.txt" >> > > sLogName = "logfilename" >> > > sDestination = "\\Storageservername\locationfoldername\" >> > > with createobject("scripting.filesystemobject") >> > > sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll >> > > for each server in split(sServerNames, vbNewLine) >> > > sLogPath = "\\" & server & "\C$\" & sLogName >> > > if .fileExists(sLogPath) then >> > > .copyfile slogpath, sDestination & server & "_" & sLogName >> > > end if >> > > next >> > > end with >> > >> > > It should create one file for each server in the specified location. >> > > _____________________ >> > > Tom Lavedas >> > > . >> >> If there are just a few differences, that could be handled as Select >> Case in place of the simpler "IF .FileExists(...)" statement, >> something like this ... >> >> Select Case True >> case .fileExists(sLogPath1) >> .copyfile slogpath, sDestination & server & sLogName1 >> case .fileExists(sLogPath2) >> .copyfile slogpath, sDestination & server & sLogName2 >> case .fileExists(sLogPath3) >> .copyfile slogpath, sDestination & server & sLogName3 >> end if >> >> Of course, the three file name variables would need to be defined >> earlier in the script. >> >> If there are many different names, it might be easier to add them as >> part of the ServerNames text file, on lofgilename per server, as >> in ... >> >> server1, logfilename.log >> server2 anothername.txt >> server3 >> etc. >> >> To simplify things a bit, a blank for the name could be used to >> indicate the use of a default name. Then the code might look like >> this ... >> >> sServerNameFile = "c:\some\local\folder\Servernames.txt" >> sDefaultLogName = "logfilename" >> sDestination = "\\Storageservername\locationfoldername\" >> with createobject("scripting.filesystemobject") >> sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll >> for each sLine in split(sServerNames, vbNewLine) >> sLine = trim(sLine) >> if not (sLine) = "" then >> aTemp = split(sLine & " " & sDefaultLogName) >> server = aTemp(0) >> sLogName = aTemp(1) >> sLogPath = "\\" & server & "\C$\" & sLogName >> if .fileExists(sLogPath) then >> .copyfile slogpath, sDestination & server & "_" & sLogName >> end if >> end if >> next >> end with >> _____________________ >> Tom Lavedas >> . >>
From: Sear S on 1 Jun 2010 07:56 Hi Tom, So I guess I will have to create three different scripts to meet the requirement of finding all 3 files since this one below doesn't work either! sServerNameFile = "\\to8pal01\express\Sam\WSnames.txt" sLogName1 = "ipc_err0.elg" sLogName2 = "ipc_err1.elg" sLogName3 = "ipc_err2.elg" sDestination = "\\to8pal01\express\Sam\Logs\" with createobject("scripting.filesystemobject") sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll for each server in split(sServerNames, vbNewLine) Select Case True case .fileExists(sLogPath1) sLogPath = "\\" & server & "\C$\" & sLogName1 .copyfile slogpath, sDestination & server & sLogName1 case .fileExists(sLogPath2) sLogPath = "\\" & server & "\C$\" & sLogName2 .copyfile slogpath, sDestination & server & sLogName2 case .fileExists(sLogPath3) sLogPath = "\\" & server & "\C$\" & sLogName3 .copyfile slogpath, sDestination & server & sLogName3 end if "Al Dunbar" wrote: > > > "Sear S" <SearS(a)discussions.microsoft.com> wrote in message > news:22ADA6AD-3CD7-4481-83CF-97BCF68E3C65(a)microsoft.com... > > Hi Tom, > > > > Thanks again! > > However I just wanted to point out that the filenames could be different > > on > > some servers but will all have the same extension > > can I use something like *.log? > > Also, I tried this argument and it didn;pt work as well as the first one > > > > sServerNameFile = "\\to8pal01\express\Sam\WSnames.txt" > > sLogName1 = "ipc_err0.elg" > > sLogName2 = "ipc_err1.elg" > > sLogName3 = "ipc_err2.elg" > > sDestination = "\\to8pal01\express\Sam\Logs\" > > with createobject("scripting.filesystemobject") > > sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll > > for each server in split(sServerNames, vbNewLine) > > sLogPath = "\\" & server & "\C$\" & sLogName > > Select Case True > > case .fileExists(sLogPath1) > > .copyfile slogpath, sDestination & server & sLogName1 > > case .fileExists(sLogPath2) > > .copyfile slogpath, sDestination & server & sLogName2 > > case .fileExists(sLogPath3) > > .copyfile slogpath, sDestination & server & sLogName3 > > end if > > I haven't followed this thread in great detail, however, the change from if > fileexists to a case structure makes me wonder if a detail has been missed. > > Each time through the select case structure above will copy at most only one > file. If all three of the files exist, the only one copied will be > "ipc_err0.elg". If it is desired to process all those that exist, you will > need an if fileexists then copy endif block for each one. > > > /Al > > > "Tom Lavedas" wrote: > > > >> On May 28, 10:30 am, Sear S <Se...(a)discussions.microsoft.com> wrote: > >> > HI Tom, > >> > > >> > A BIG THANK YOu this works perfectly!! > >> > If the file name on some servers is different than the one mentioned in > >> > the > >> > Slogname section then can I add more file names as below? > >> > > >> > sServerNameFile = "c:\some\local\folder\Servernames.txt" > >> > > >> > > sLogName = "logfilename,logfilename2, etc..." > >> > > sDestination = "\\Storageservername\locationfoldername\" > >> > > with createobject("scripting.filesystemobject") > >> > > sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll > >> > > for each server in split(sServerNames, vbNewLine) > >> > > sLogPath = "\\" & server & "\C$\" & sLogName > >> > > if .fileExists(sLogPath) then > >> > > .copyfile slogpath, sDestination & server & "_" & sLogName > >> > > end if > >> > > next > >> > > end with > >> > "Tom Lavedas" wrote: > >> > > On May 27, 3:57 pm, Sear S <Se...(a)discussions.microsoft.com> wrote: > >> > > > Hi Tom, > >> > > >> > > > Ok let me explain in details what I exactly want to accomplish: > >> > > >> > > > I need a script that I can use to gather a log file from a number > >> > > > of > >> > > > workstations...in total 40 workstations > >> > > > The log file is located on C:\logfilename of each one of those > >> > > > workstations... > >> > > > I have full admin access to those PCs therefore permissions won't > >> > > > be an issue! > >> > > > Once I ran the script, I would like it to copy all those log files > >> > > > from > >> > > > those machines and put them somewhere on a shared drive for me... > >> > > > I hope that clarifies a little bit my point > >> > > >> > > > Thanks > >> > > >> > > > Sam > >> > > >> > > OK, from what you said, you just need to change the value of sLogName > >> > > to be "logfilename" and the sDestination content to be "\ > >> > > \Storageservername\locationfoldername\" and complete the list of > >> > > server names. > >> > > >> > > sServerNames = "server1,server2,server3,etc" > >> > > sLogName = "logfilename" > >> > > sDestination = "\\Storageservername\locationfoldername\" > >> > > with createobject("scripting.filesystemobject") > >> > > for each server in split(sServerNames, ",") > >> > > sLogPath = "\\" & server & "\C$\" & sLogName > >> > > if .fileExists(sLogPath) then > >> > > .copyfile slogpath, sDestination & server & sLogName > >> > > end if > >> > > next > >> > > end with > >> > > >> > > Of course, 40 server names would be a problem in the SET statement, > >> > > so > >> > > a file list (one name per line) would be better, something like > >> > > this ... > >> > > >> > > sServerNameFile = "c:\some\local\folder\Servernames.txt" > >> > > sLogName = "logfilename" > >> > > sDestination = "\\Storageservername\locationfoldername\" > >> > > with createobject("scripting.filesystemobject") > >> > > sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll > >> > > for each server in split(sServerNames, vbNewLine) > >> > > sLogPath = "\\" & server & "\C$\" & sLogName > >> > > if .fileExists(sLogPath) then > >> > > .copyfile slogpath, sDestination & server & "_" & sLogName > >> > > end if > >> > > next > >> > > end with > >> > > >> > > It should create one file for each server in the specified location. > >> > > _____________________ > >> > > Tom Lavedas > >> > > . > >> > >> If there are just a few differences, that could be handled as Select > >> Case in place of the simpler "IF .FileExists(...)" statement, > >> something like this ... > >> > >> Select Case True > >> case .fileExists(sLogPath1) > >> .copyfile slogpath, sDestination & server & sLogName1 > >> case .fileExists(sLogPath2) > >> .copyfile slogpath, sDestination & server & sLogName2 > >> case .fileExists(sLogPath3) > >> .copyfile slogpath, sDestination & server & sLogName3 > >> end if > >> > >> Of course, the three file name variables would need to be defined > >> earlier in the script. > >> > >> If there are many different names, it might be easier to add them as > >> part of the ServerNames text file, on lofgilename per server, as > >> in ... > >> > >> server1, logfilename.log > >> server2 anothername.txt > >> server3 > >> etc. > >> > >> To simplify things a bit, a blank for the name could be used to > >> indicate the use of a default name. Then the code might look like > >> this ... > >> > >> sServerNameFile = "c:\some\local\folder\Servernames.txt" > >> sDefaultLogName = "logfilename" > >> sDestination = "\\Storageservername\locationfoldername\" > >> with createobject("scripting.filesystemobject") > >> sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll > >> for each sLine in split(sServerNames, vbNewLine) > >> sLine = trim(sLine) > >> if not (sLine) = "" then > >> aTemp = split(sLine & " " & sDefaultLogName) > >> server = aTemp(0) > >> sLogName = aTemp(1) > >> sLogPath = "\\" & server & "\C$\" & sLogName > >> if .fileExists(sLogPath) then > >> .copyfile slogpath, sDestination & server & "_" & sLogName > >> end if > >> end if > >> next > >> end with > >> _____________________ > >> Tom Lavedas > >> . > >> > . >
From: Tom Lavedas on 1 Jun 2010 08:40 On Jun 1, 7:56 am, Sear S <Se...(a)discussions.microsoft.com> wrote: > Hi Tom, > > So I guess I will have to create three different scripts to meet the > requirement of finding all 3 files since this one below doesn't work either! > That is a change from what I thought you were doing. I see now that there was an obvious logic error in my last posting, for which I apologize. Lets try again, though I think you may want to try working on this on your own, as I can only afford to spend a few minutes at a time on something like this. Since, it is your problem, you would probably have better luck applying the principles and fixing my logic bugs. For multiple files, I might try something like this ... sServerNameFile = "\\to8pal01\express\Sam\WSnames.txt" aLogNames = Array("ipc_err0.elg", "ipc_err1.elg", "ipc_err2.elg") sDestination = "\\to8pal01\express\Sam\Logs\" with createobject("scripting.filesystemobject") sServerNames = .OpenTextFile(sServerNameFile, 1).ReadAll for each server in split(sServerNames, vbNewLine) for each sLogName in aLogNames sLogPath = "\\" & server & "\C$\" & sLogName if .fileExists(sLogPath) then .copyfile slogPath, sDestination & server & sLogName end if next next end with _____________________ Tom Lavedas
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: BUY FAKE PASSPORTS OF CANADA,FAKE CANADIAN PASSPORTS FOR SALE! FAK Next: Specify open file with Excel 2007 |