From: Jake on 9 Mar 2010 02:37 Hi, I have a folder called E:\MyFolder which contains an arbitrary number of subfolders like Sub1, Sub2 Sub3 etc. In each of these folders there might be a file called MyFile.DAT. I need a script that loops through all levels of subfolders under E:\MyFolder and copies every occurrence of MyFile.DAT to E:\Target. In the copying process each Myfile.DAT is renamed according to the subfolder it was found in, like: Sub1-Myfile.DAT, Sub2-Myfile.DAT etc... How would I do that in vbscript...? Thanks for any help on this regards jake
From: Pegasus [MVP] on 9 Mar 2010 03:10 "Jake" <jake44(a)gmail.com> wrote in message news:uaxZkt1vKHA.1984(a)TK2MSFTNGP05.phx.gbl... > Hi, > > I have a folder called E:\MyFolder which contains an arbitrary number of > subfolders like Sub1, Sub2 Sub3 etc. > > In each of these folders there might be a file called MyFile.DAT. > > I need a script that loops through all levels of subfolders under > E:\MyFolder and copies every occurrence of MyFile.DAT to E:\Target. In > the copying process each Myfile.DAT is renamed according to the subfolder > it was found in, like: Sub1-Myfile.DAT, Sub2-Myfile.DAT etc... > > How would I do that in vbscript...? > > Thanks for any help on this > > regards > > jake The wheel you're inventing has already been invented and is implemented in the downloadable utility xxcopy.exe. Its author calls it "to flatten a directory" and invokes it with the /SL command line switch. If you prefer to roll your own script then I suggest you post the basic sctructure and let respondents help you with some of the details.
From: Reventlov on 9 Mar 2010 17:14 Il giorno Tue, 9 Mar 2010 09:10:23 +0100, "Pegasus [MVP]" <news(a)microsoft.com> ha scritto: >"Jake" <jake44(a)gmail.com> wrote in message >> I have a folder called E:\MyFolder which contains an arbitrary number of >> subfolders like Sub1, Sub2 Sub3 etc. >> >> In each of these folders there might be a file called MyFile.DAT. >> >> I need a script that loops through all levels of subfolders under >> E:\MyFolder and copies every occurrence of MyFile.DAT to E:\Target. In >> the copying process each Myfile.DAT is renamed according to the subfolder >> it was found in, like: Sub1-Myfile.DAT, Sub2-Myfile.DAT etc... >The wheel you're inventing has already been invented and is implemented in >the downloadable utility xxcopy.exe. Its author calls it "to flatten a >directory" and invokes it with the /SL command line switch. If you prefer to >roll your own script then I suggest you post the basic sctructure and let >respondents help you with some of the details. With dir /s /b myfile.dat >list.txt it is possible to have a list of all the pathnames of the several myfile.dat under the current directory. -- Giovanni Cenati (Bergamo, Italy) Write to "Reventlov" at katamail com http://digilander.libero.it/Cenati (Esempi e programmi in VbScript) --
From: Jake on 10 Mar 2010 02:33 Den 09.03.2010 09:10, skreiv Pegasus [MVP]: > > > "Jake" <jake44(a)gmail.com> wrote in message > news:uaxZkt1vKHA.1984(a)TK2MSFTNGP05.phx.gbl... >> Hi, >> >> I have a folder called E:\MyFolder which contains an arbitrary number >> of subfolders like Sub1, Sub2 Sub3 etc. >> >> In each of these folders there might be a file called MyFile.DAT. >> >> I need a script that loops through all levels of subfolders under >> E:\MyFolder and copies every occurrence of MyFile.DAT to E:\Target. In >> the copying process each Myfile.DAT is renamed according to the >> subfolder it was found in, like: Sub1-Myfile.DAT, Sub2-Myfile.DAT etc... >> >> How would I do that in vbscript...? >> >> Thanks for any help on this >> >> regards >> >> jake > >If you prefer to roll your own script then I suggest you post the basic > sctructure and let respondents help you with some of the details. Hi, I have tried to put something together. I'm almost there, I just need help in extracting the actual foldername (and NOT full path) of a file from complete path: C:\MyFolder\Sub1\Sub-A\MyFile.DAT From the complete path above I need to extract 'Sub-A'. I.e. the name of the folder where MyFile.DAT exists. How do I do that? I have tried all the fso methods but none seems to return what I need. regards Tor
From: Pegasus [MVP] on 10 Mar 2010 04:13 "Jake" <jake44(a)gmail.com> wrote in message news:e0k7NQCwKHA.4492(a)TK2MSFTNGP05.phx.gbl... > Den 09.03.2010 09:10, skreiv Pegasus [MVP]: >> >> >> "Jake" <jake44(a)gmail.com> wrote in message >> news:uaxZkt1vKHA.1984(a)TK2MSFTNGP05.phx.gbl... >>> Hi, >>> >>> I have a folder called E:\MyFolder which contains an arbitrary number >>> of subfolders like Sub1, Sub2 Sub3 etc. >>> >>> In each of these folders there might be a file called MyFile.DAT. >>> >>> I need a script that loops through all levels of subfolders under >>> E:\MyFolder and copies every occurrence of MyFile.DAT to E:\Target. In >>> the copying process each Myfile.DAT is renamed according to the >>> subfolder it was found in, like: Sub1-Myfile.DAT, Sub2-Myfile.DAT etc... >>> >>> How would I do that in vbscript...? >>> >>> Thanks for any help on this >>> >>> regards >>> >>> jake >> >>If you prefer to roll your own script then I suggest you post the basic >> sctructure and let respondents help you with some of the details. > > Hi, > > I have tried to put something together. I'm almost there, I just need > help in extracting the actual foldername (and NOT full path) of a file > from complete path: > > C:\MyFolder\Sub1\Sub-A\MyFile.DAT > > From the complete path above I need to extract 'Sub-A'. I.e. the name of > the folder where MyFile.DAT exists. > > How do I do that? I have tried all the fso methods but none seems to > return what I need. > > regards > > Tor With oFSO it's usually the .Name property that gives you the file or folder name, as opposed to the .Path property. If you post the relevant part of your code then someone will show you how it's done.
|
Next
|
Last
Pages: 1 2 Prev: Can a vbscript identify the program/process that called a vbsc Next: SQL Query in VBScript |