Jump to content

Recommended Posts

Posted (edited)

Hi

I am in need of some help with a routine that will compress system files, is there anyone here willing to help with a routine that will use Makecab to compress system files?

I am having problems at the moment as the path to the files that needs compressing has spaces in them and the routine i am using will not work.

This is the only thing that is holding me back at the moment.

Many Thanks for any help.

Regards

Worf

Edited by Worf

Posted

Try this script, this script was placed in the same folder as the files I was testing makecab on.

Here is the path and file names I tested with this script.

E:\Test Make Cab\Tick Tick Boom(The Hives(Rock_2007)).wmv
E:\Test Make Cab\Stuck In The Middle With You(Stealers Wheel(Pop_1973)).wma
E:\Test Make Cab\Chop Suey(System Of A Down(Rock_2001)).wma

Save As TestMKCab.vbs

Dim Act :Set Act = CreateObject("Wscript.Shell")
Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
Dim Fld :Set Fld = Fso.GetFolder(".")
Dim F1
For Each F1 In Fld.Files
If InStr(LCase(F1.Path),LCase(".vbs")) Then
Else
Act.Run( _
"%Comspec% /c @Echo Off && CLS && COLOR F3 && MODE 89,9 && " & _
"makecab /D CompressionType=LZX /D CompressionMemory=21 " &_
Chr(34) & F1.Path & Chr(34)),1,True
End If
Next

Posted

I wrote 2 vbs script that will makecab and expand files. All you have to do is drag a file onto the script.

Save As DragDropMkCab.vbs

Dim Act :Set Act = CreateObject("Wscript.Shell")
Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
Dim Col, Obj
If Wscript.Arguments.Count = 0 Then
Act.Popup "This needs a file drag on to this script.",0,"No File Error",4128
Else
For Each Col In Wscript.Arguments
If Fso.FileExists(Col) Then
If Right(InStr(Col,"."),5) Then
Set Obj = Fso.GetFile(Col)
Act.CurrentDirectory = Fso.GetParentFolderName(Obj.Path)
Act.Run( _
"%Comspec% /c @Echo Off && CLS && COLOR F3 && MODE 89,9 && " & _
"makecab /D CompressionType=LZX /D CompressionMemory=21 " &_
Chr(34) & Obj.Path & Chr(34)),1,True
End If
End If
Next
End If

Save As DragDropExpand.vbs

Dim Act :Set Act = CreateObject("Wscript.Shell")
Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
Dim Col, Obj
If Wscript.Arguments.Count = 0 Then
Act.Popup "This needs a file drag on to this script.",0,"No File Error",4128
Else
For Each Col In Wscript.Arguments
If Fso.FileExists(Col) Then
If Right(InStr(Col,"_"),1) Then
Set Obj = Fso.GetFile(Col)
Act.CurrentDirectory = Fso.GetParentFolderName(Obj.Path)
Act.Run( _
"%Comspec% /c @Echo Off && CLS && COLOR F3 && MODE 89,9 && " & _
"EXPAND " & Chr(34) & Obj.Path & Chr(34) & " /R"),1,True
End If
End If
Next
End If

Posted

Hi gunsmokingman

Thank you for your scripts. I was looking for an actual Visual Studio routine that would get a list of files from a folder and then compress then files into another folder.

Posted

Thank you gunsmokingman

I am very greatful for you to take you time writting this routine. I will integrate this into my program and once that is done i can then get on with the next part.

Many Thanks

Worf

  • 9 months later...
Posted

Worf, although you may no longer have a need to re-visit it, the topic may remain useful to others and will therefore remain open for future additions.

Posted

I am obviously missing something here :ph34r:, but for the little good it may be :unsure:, this batch does provide drag 'n drop makecabbing:

dragncab.cmd

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
SET File=%1
SET FilePath="%~dp1"
SET FilePath=%FilePath:~0,-2%"
SET FileExt=%~x1
SET LastChar=%FileExt:~-1,1%
IF %LastChar%.==_. (Extrac32.exe /Y /L %FilePath% %File%) ELSE (makecab %File% /L %FilePath%)

jaclaz

Posted

Worf this wasnt for your project, this was more to see if could code a drag and drop app.I know in vbs there a limit to how many items can be drag and drop on to it, I think it limit is 24 items. I dont know if that limit exists in cmd promt, but in Vb.net I have not hit a limit yet.

I am obviously missing something here

jaclaz the purpose of thread like these are to help people to learn new things.

For jaclaz code only

The flaw is that they appear to run makecab on any file which doesn't end with an underscore

That didnt happen on mine because of this line

If Not Microsoft.VisualBasic.Right(I, 1) = "_" Then

I have updated this app and started a new Thread

New App

New Source Code

Posted

I also created a 'packaged' batch file a couple of years ago to provide this functionality.

I wasn't going to include the above link, but decided to do so due to a potential flaw in the posted versions. The flaw is that they appear to run makecab on any file which doesn't end with an underscore; mine will 'hopefully' run it on any file which is not already 'cabbed' in the directory, (and upon success delete the 'un-cabbed' version). Cabbed files are not required to use the trailing underscore character and obviously .cab files may also exist in the selected directory.

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...