April 17, 200917 yr HiI 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.RegardsWorf Edited April 17, 200917 yr by Worf
April 17, 200917 yr 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)).wmvE:\Test Make Cab\Stuck In The Middle With You(Stealers Wheel(Pop_1973)).wmaE:\Test Make Cab\Chop Suey(System Of A Down(Rock_2001)).wmaSave As TestMKCab.vbsDim 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
April 17, 200917 yr 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.vbsDim 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 IfSave As DragDropExpand.vbsDim 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
April 17, 200917 yr Author Hi gunsmokingmanThank 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.
April 19, 200917 yr Author Thank you gunsmokingmanI 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 ThanksWorf
January 29, 201016 yr 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.
January 29, 201016 yr I am obviously missing something here , but for the little good it may be , this batch does provide drag 'n drop makecabbing:dragncab.cmd@ECHO OFFSETLOCAL ENABLEEXTENSIONSSET File=%1SET FilePath="%~dp1"SET FilePath=%FilePath:~0,-2%"SET FileExt=%~x1SET LastChar=%FileExt:~-1,1%IF %LastChar%.==_. (Extrac32.exe /Y /L %FilePath% %File%) ELSE (makecab %File% /L %FilePath%)jaclaz
January 29, 201016 yr 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 herejaclaz the purpose of thread like these are to help people to learn new things.For jaclaz code onlyThe flaw is that they appear to run makecab on any file which doesn't end with an underscoreThat didnt happen on mine because of this lineIf Not Microsoft.VisualBasic.Right(I, 1) = "_" ThenI have updated this app and started a new ThreadNew AppNew Source Code
January 29, 201016 yr I also created a 'packaged' batch file a couple of years ago to provide this functionality.See here!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.
Create an account or sign in to comment