troubleshooting Question

VBSCRIPT

Avatar of lsbrown1
lsbrown1 asked on
Windows Server 2003VB Script
1 Comment1 Solution2001 ViewsLast Modified:
I have written a vbscript to Scans Lanier Folder And Copies Files To The Appropriate Departmental Directory. The script I wrote  does reads and scans Lanier Folder on dirve c:\scans but it does not
Copies Files To The Appropriate Departmental Directory. Please view my VBSRIPT to detect error/s
that not letting my script Copies Files To The Appropriate Departmental Directory. I'm new at writing vbscripts. This the script i wrote below
'***** Scans Lanier Folder And Copies Files To The Appropriate Departmental Directory *****

'***** Setup *****
  On Error Resume Next
  Const ForAppending = 8
  Const FILE_NAME = 0
  Set objShell = CreateObject ("Shell.Application")
  Set objFolder = objShell.Namespace ("C:\SCANS")

  Set objFSODel = CreateObject("Scripting.FileSystemObject")

  Const OverwriteExisting = TRUE
  Set objFSOCopy = CreateObject("Scripting.FileSystemObject")

  Set objFSOLog = CreateObject("Scripting.FileSystemObject")
  Set objTextFile = objFSOLog.OpenTextFile ("LSCAN.LOG", ForAppending, True)
 
'*****

      



'***** Main Loop - Begin *****
Do

  '*** Read Scan Directory - C:\SCANS ***
    For Each strFileName in objFolder.Items
      WScript.Echo
      Wscript.Echo "File Found... " & objFolder.GetDetailsOf (strFileName, FILE_NAME)

      '*** Clear Variables ***
         strDept=""
         strFileSplit=""
         strFileDept=""
      '***
     
      '*** Parse File And Identify File Destination '***
         strFileSplitArray=Split(objFolder.GetDetailsOf (strFileName, FILE_NAME),"_")
         strFileSplit=UCase(Trim(strFileSplitArray(0)))
         strFileDept=Mid(strFileSplit,5,3)
      '***





    If strFileDept<>"" And Len(strFileSplit)=10 And UCase(Left(strFileSplit,4))="APRT" Then

      '*** Check If Directory Is Created And Create As Necessary ***

         '*** Check If Folder Exists ***
           Set objFSO = CreateObject("Scripting.FileSystemObject")

           If objFSO.FolderExists("U:\"&strFileDept&".DPT\SCAN") Then
           Else

               '***** Create Folder *****
                 Set objFSOCreate = CreateObject("Scripting.FileSystemObject")
                 Set objFolderCreate = objFSOCreate.CreateFolder("U:\"&strFileDept&".DPT")
                 Set objFolderCreate = objFSOCreate.CreateFolder("U:\"&strFileDept&".DPT\SCAN")
                 objTextFile.WriteLine(Now&" Create Folder: U:\"&strFileDept&".DPT\SCAN")
             '*****
           End If
         '***
      
         
         
      '***

      '*** Copy File ***
        WScript.Echo "   Copying File...  " & objFolder.GetDetailsOf (strFileName, FILE_NAME)
        strExtension=Right(Trim(objFolder.GetDetailsOf (strFileName, FILE_NAME)),4)
        strSplitTime=Split(Time,":")
        strTimeNow=strSplitTime(0)&strSplitTime(1)&Left(strSplitTime(2),2)
        strDateTime=Day(Date)&Month(Date)&Year(Date)&"_"&strTimeNow
        strCopyFile="U:\"&strFileDept&".DPT\SCAN\"&strFileSplit&"_"&strDateTime&strExtension
        objFSOCopy.CopyFile "C:\SCANS\" & objFolder.GetDetailsOf (strFileName, FILE_NAME) , strCopyFile, OverwriteExisting
        objTextFile.WriteLine(Now&" Copy File: C:\SCANS\" & objFolder.GetDetailsOf (strFileName, FILE_NAME)&" "&strCopyFile)
      '***

      '*** Delete File ***
        WScript.Echo "   Deleting File... " & objFolder.GetDetailsOf (strFileName, FILE_NAME)
        objFSODel.DeleteFile("C:\SCANS\"&objFolder.GetDetailsOf (strFileName, FILE_NAME))
        objTextFile.WriteLine(Now&" Delete File: C:\SCANS\" & objFolder.GetDetailsOf (strFileName, FILE_NAME))
        objTextFile.WriteLine("")
      '***

     Else

    End If  


   WScript.Sleep (1000)




    Next
  '***


  '*** Wait/Sleep 5 Seconds ***
    WScript.Echo
    WScript.Echo
    WScript.Echo "Sleeping 5 Seconds... "&Now
    WScript.Sleep (5000)
  '***

Loop
'***** Main Loop - End *****
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros