|
server
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
File copy and paste scriptHi,
I need to traverse a bunch of folders looking for files whose name contain "MyPhrase" in them and copy them into a folder on say my desktop. I'd appreciate some pointers in writing this script. Basically, I want to tell the script what folder to start from. It will go through all its subfolders and whenever it finds "MyPhrase" in file name, it will copy and paste that file into a folder on my desktop. Thanks for your help. -- Thanks, Sam
Show quote
Hide quote
"Sam" <S**@discussions.microsoft.com> wrote in message Try this script:news:76989B96-44F6-4D4C-992C-B0A64653DDA7@microsoft.com... > Hi, > > I need to traverse a bunch of folders looking for files whose name contain > "MyPhrase" in them and copy them into a folder on say my desktop. I'd > appreciate some pointers in writing this script. > > Basically, I want to tell the script what folder to start from. It will go > through all its subfolders and whenever it finds "MyPhrase" in file name, > it > will copy and paste that file into a folder on my desktop. > > Thanks for your help. > -- > Thanks, > > Sam Set oFSO = CreateObject("Scripting.FileSystemObject") sFolder = "d:\Some Folder" sPhrase = "Some Phrase" CheckFolder oFSO.GetFolder(sFolder) '-------------------------- 'Check a folder recursively '-------------------------- Sub CheckFolder(oFolder) For Each oFile In oFolder.Files If InStr(1, oFile.Name, sPhrase, 1) > 0 Then WScript.Echo "Copying " & oFile.path End If Next For Each oSubfolder In oFolder.Subfolders CheckFolder oSubfolder Next End Sub I leave it to you to implement the functions that will prompt the user for a folder name and the one that performs the actual copy action.
Batch Script to parse lines in text file
Command line parameters? Get attributes of user list from AD run once script Monitor redundent processes running on the Windows Server Deleting and re-installing printer with new name using login scrip send mail if ping faile WMI Script, access denied? Echo to column position Script for deleting folders + content in root of D:\ after # days |
|||||||||||||||||||||||