Hi Rick,
One last thing…
This is my current code
Sub ZipIt (source, dest) '** VBS Script to zip files from folder [source] to zip file [dest] **
Dim fso, winShell, of
Set fso = CreateObject(“Scripting.FileSystemObject”)
Set winShell = createObject(“shell.application”)
Set of = fso.CreateTextFile(dest, True)
of.write(“PK” & chr(5) & chr(6) & string(18,chr(0))) '**Make an empty Zip File
of.Close
Set of = nothing
Set fso = nothing
Dim oft, ofs
Set oft = winShell.NameSpace(dest)
Set ofs = winShell.NameSpace(source)
if oft is nothing Then WScript.Echo “Dest Fail !!!”
if ofs is nothing Then WScript.Echo “Source Fail !!!”
oft.CopyHere ofs.Items '** Copy files
Do until oft.items.Count >= ofs.items.Count '** Wait copy to finish
WScript.sleep 1000
Loop
Wscript.Echo “Zip completed”
Set oft = nothing
Set ofs = nothing
Set winShell = Nothing
End Sub
ZipIt “C:\Users\PRESAR~1\DOCUME~1\JONESQ~1”, “C:\Users\PRESAR~1\DOCUME~1\JONESQ~1.zip”
What I am doing is creating a zip file from my RealStudio program via a .vbs script
So, in my app I will create the .vbs script then launch it.
In creating the .vbs script I compose the line
ZipIt “C:\Users\PRESAR~1\DOCUME~1\JONESQ~1”, “C:\Users\PRESAR~1\DOCUME~1\JONESQ~1.zip”
like this
"ZipIt " + chr(34) + app.gMyVeryLongNameFolder.Shellpath + chr(34) + ", " + chr(34) + app.gMyVeryLongNameFolder.Shellpath + “.zip” + chr(34)
Everything is fine so far. The problem is this
The source folder, app.gMyVeryLongNameFolder, has a very long name, so in the created .vbs script it is this
ZipIt “C:\Users\PRESAR~1\DOCUME~1\JONESQ~1”, “C:\Users\PRESAR~1\DOCUME~1\JONESQ~1.zip”
PRESAR~1 is suppose to be Presario User
DOCUME~1 is suppose to be Documents
JONESQ~1 is a very long name which will vary from user to user
As you notice the zip file on disk is named JONESQ~1.zip and that is my problem.
I would like it to have its original very long name. How can I achieve that?
I have a thought but I do not know how to do it, my thought is this…
If this line
oft.CopyHere ofs.Items '** Copy files
could be modified to create another folder with whatever name is OK, and put the Zip in that folder.
Something like this in PseudoCode
Dim MyEnclosingFolder as folder item
MyEnclosingFolder = oft.Parent.Child(“Whatever name is suitable”)
MyEnclosingFolder.CopyHere ofs.Items
Just my thought.
Lennox