?
Solved

VBScripting folder names with space issue's

Posted on 2006-05-31
3
Medium Priority
?
399 Views
Last Modified: 2008-02-01
I have created a VBScript to zip a folder to a file in another folder.  So far this has worked as like charm until I cam accross folders with spaces etc...

I have searched high and low....and can not seem to solve this issue.  I must be overlooking something, and this should be simple!  As the case may be I am in urgent need to complete this script so I have put a 500 point value on it.

Below is the script I have created, you will need the Winzip to complete this task.

NOTE:  WE CAN NOT USE THE WINZIP ADDON TO DO COMMAND LINE.............

Dim Wshell,fso,fld,fil,FileList
Set fso = CreateObject("Scripting.FileSystemObject")
Set Wshell = CreateObject("Wscript.Shell")

'delete if exists folder
If fso.FolderExists("c:\test")Then
      fso.DeleteFolder("c:\test")
End If

'create folder
Set fld =fso. CreateFolder("c:\test")

'folder and files to capture
Set fld0 = fso.GetFolder("C:\Program Files\Windows NT")  ' this seems to get truncated and will not zip up

' zip the files
Wshell.Run "winzip -min  -a -r C:\test\winnt.zip " &  fld0

'cleanup
Set Wshell = Nothing
Set fld = Nothing
Set fld0 = Nothing
Set fso = Nothing

0
Comment
Question by:jvpohl
  • 2
3 Comments
 

Author Comment

by:jvpohl
ID: 16804747
here are the result from winzip:

Action: Add (and replace) files Include subfolders: yes Save full path: no
Warning: name not matched: C:\Program
Warning: name not matched: Files\Windows
Warning: name not matched: NT
Error: No files were found for this action that match your criteria - nothing to do. (C:\test\winnt.zip)
0
 

Author Comment

by:jvpohl
ID: 16804899
Ok...not really sure how to cancel this.....but I have the answer!  

DOS IS KILLING ME!!!!!  

Dim Wshell,fso,fld,fil,FileList
Set fso = CreateObject("Scripting.FileSystemObject")
Set Wshell = CreateObject("Wscript.Shell")

'delete if exists folder
If fso.FolderExists("c:\test")Then
      fso.DeleteFolder("c:\test")
End If

'create folder
Set fld =fso. CreateFolder("c:\test")

'folder and files to capture
Set fld0 = fso.GetFolder("C:\progra~1\window~1")  ' this works perfectly!

' zip the files
Wshell.Run "winzip -min  -a -r -p -es -hs  C:\test\winnt.zip " & fld0

'cleanup
Set Wshell = Nothing
Set fld = Nothing
Set fld0 = Nothing
Set fso = Nothing
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 16804932
Try enclosing the path in quotes:   (you don't need fso.GetFolder either)

    'folder and files to capture
    fld0 = "C:\Program Files\Windows NT"

    ' zip the files
     Wshell.Run "winzip -min  -a -r -p -es -hs  C:\test\winnt.zip " & Chr(34) & fld0 & Chr(34)

Remove this line:

    Set fld0 = Nothing

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Progress

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question