Copy multiple files/multiple subdirectories to backup folder


I'm trying to write a script to backup our databases, when run. Each of our databases consists of 12 indivdual files, and there are about 100 databases, stored in different subdirectories. I'm trying to simply make copies of these files into a specified directory, then I can burn the contents to CD-ROM.

This is the (non functioning) script that I've got so far....

Dim FSO, FolderRoot, FolderList, FolderName, Listing, SubFolder, FolderPath
Set FSO = CreateObject("Scripting.FileSystemObject")
Set FolderRoot = FSO.GetFolder("Q:\Textbase\")
Set FolderList = FolderRoot.SubFolders

For Each FolderName in FolderList
      Listing = Listing &
      FolderPath = "Q:\Textbase\"&Listing
      ACF = FolderPath&"\*.acf"
      BTX = FolderPath&"\*.btx"
      INI = FolderPath&"\*.ini"
      TBA = FolderPath&"\*.tba"
      DBO = FolderPath&"\*.dbo"
      DBR = FolderPath&"\*.dbr"
      DBS = FolderPath&"\*.dbs"
      IXL = FolderPath&"\*.ixl"
      OCC = FolderPath&"\*.occ"
      SDO = FolderPath&"\*.sdo"
      SLT = FolderPath&"\*.slt"
      LOG = FolderPath&"\*.log"
      'MsgBox ACF & vbCrLF & BTX & vbCrLF & INI & vbCrLF & TBA & vbCrLF & DBO & vbCrLF & DBR & vbCrLF & DBS & vbCrLF & IXL & vbCrLF & OCC & vbCrLF & SDO & vbCrLF & LOG & vbCrLF & SLT, VBOKOnly, "DB/TextWorks Backup System"
            If FSO.FileExists(ACF) Then
                  FSO.CopyFile ACF,"Q:\Textbase\!CD Burning"
                  FSO.CopyFile BTX,"Q:\Textbase\!CD Burning"
                  FSO.CopyFile INI,"Q:\Textbase\!CD Burning"
                  FSO.CopyFile TBA,"Q:\Textbase\!CD Burning"
                  FSO.CopyFile DBO,"Q:\Textbase\!CD Burning"
                  FSO.CopyFile DBR,"Q:\Textbase\!CD Burning"
                  FSO.CopyFile DBS,"Q:\Textbase\!CD Burning"
                  FSO.CopyFile IXL,"Q:\Textbase\!CD Burning"
                  FSO.CopyFile OCC,"Q:\Textbase\!CD Burning"
                  FSO.CopyFile SDO,"Q:\Textbase\!CD Burning"
                  FSO.CopyFile SLT,"Q:\Textbase\!CD Burning"
                  FSO.CopyFile LOG,"Q:\Textbase\!CD Burning"
            End If
      Listing = ""

MsgBox "Backup Complete", VBOKOnly, "DB/TextWorks Backup System"

Set FSO = Nothing
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
Have you considered just using plain old xcopy in a batch file?

Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
                           [/C] [/I] [/Q] [/F] [/L] [/H] [/R] [/T] [/U]
                           [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]

  source       Specifies the file(s) to copy.
  destination  Specifies the location and/or name of new files.
  /A           Copies only files with the archive attribute set,
               doesn't change the attribute.
  /M           Copies only files with the archive attribute set,
               turns off the archive attribute.
  /D:m-d-y     Copies files changed on or after the specified date.
               If no date is given, copies only those files whose
               source time is newer than the destination time.
               Specifies a list of files containing strings.  When any of the
               strings match any part of the absolute path of the file to be
               copied, that file will be excluded from being copied.  For
               example, specifying a string like \obj\ or .obj will exclude
               all files underneath the directory obj or all files with the
               .obj extension respectively.
  /P           Prompts you before creating each destination file.
  /S           Copies directories and subdirectories except empty ones.
  /E           Copies directories and subdirectories, including empty ones.
               Same as /S /E. May be used to modify /T.
  /V           Verifies each new file.
  /W           Prompts you to press a key before copying.
  /C           Continues copying even if errors occur.
  /I           If destination does not exist and copying more than one file,
               assumes that destination must be a directory.
  /Q           Does not display file names while copying.
  /F           Displays full source and destination file names while copying.
  /L           Displays files that would be copied.
  /H           Copies hidden and system files also.
  /R           Overwrites read-only files.
  /T           Creates directory structure, but does not copy files. Does not
               include empty directories or subdirectories. /T /E includes
               empty directories and subdirectories.
  /U           Copies only files that already exist in destination.
  /K           Copies attributes. Normal Xcopy will reset read-only attributes.
  /N           Copies using the generated short names.
  /O           Copies file ownership and ACL information.
  /X           Copies file audit settings (implies /O).
  /Y           Suppresses prompting to confirm you want to overwrite an
               existing destination file.
  /-Y          Causes prompting to confirm you want to overwrite an
               existing destination file.
  /Z           Copies networked files in restartable mode.
ijeAuthor Commented:
Thanks Idle_Mind, but I really need something I can setup for less techincal people to use (I'm going to stick a shortcut in their menu, give a nice Windows MsgBox at the end). If it looks like DOS, or requires DOS input, they'll freak..... :(

Also, I don't want to retain the folder structure - I just want to be able to trawl through all of the subdirectories of "Q:\Textbase" and dump all of the specified 12 formats into the "Q:\!CD Backup" folder.

Thanks for your input through - I haven't even thought about using batch files for years!!! :)
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
I can write it in VB but have had only limited experience with script.  Are you set on only using script?

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

ijeAuthor Commented:
Yes, def. need in VBScript - will eventually be ties into a seperate document logging script I have....
All files, including nested subdirectories and their files, will be removed from disk with this program.

Sub Command1_Click()
  Dim TempDir As String
  TempDir = "C:\TEST"
  Nuke TempDir
End Sub

Sub Nuke(DirName As String)
  Const ATTR_NORMAL = 0

  Dim OriginalDir, FileName, NextFileName As String

  OriginalDir = CurDir$
  ChDir DirName
  FileName = Dir$("*.*", ATTR_NORMAL)
  Do While FileName <> ""
      Kill FileName
      FileName = Dir$

    FileName = Dir$("*.*", ATTR_DIRECTORY)
    While FileName = "." Or FileName = ".."
    FileName = Dir$

    If FileName = "" Then Exit Do
    Nuke (FileName)

  ChDir OriginalDir
  RmDir DirName
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered mccainz2
Please leave any comments here within the next seven days.


EE Cleanup Volunteer
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.