MAKECAB - Multiple driver files to compress

Discussion in 'Scripting' started by tnx, Jul 2, 2012.

  1. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,601
    227
    60
    Hi all.

    tn messing again and once again in need of some pointers.

    What I am trying to do is compress some drivers.
    I have this script

    This does one file and I have to use "RUN"...

    What I would like to know is how to write it so ALL the files in a particular fo;der,say C:\XP\1 are compressed and end up in anotheer folder,say C:\XP\2

    I have tried *.* but it dont work ???

    And how do I script it to become a .bat or .cmd so I can just click on it to start it going..

    Hope this makes sence. Scripting is probebly my weak point...

    Any tips or advice would be very welcome..

    Cheers
     
  2. Tito

    Tito Super Mod / Adviser
    Staff Member

    Nov 30, 2009
    17,372
    15,018
    340
    As far I know, by 7-Zip you can create cab archive in GUI.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,601
    227
    60
    Would that not just make one big file. I would like to make each file seperately....

    Will have a look at it though

    Cheers..
     
  4. Tito

    Tito Super Mod / Adviser
    Staff Member

    Nov 30, 2009
    17,372
    15,018
    340
    #4 Tito, Jul 2, 2012
    Last edited by a moderator: Apr 20, 2017
    Code:
    makecab %~dp0*.cat %~dp0*.ca_
    
    Try this ;)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,601
    227
    60
    #5 tnx, Jul 2, 2012
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Right I have that copied....

    Exactly how will this work....Sorry..

    would it be

    What I dont understand is,how does this point to a particular folder ?

    Do i save it as .cmd,copy this file into my chosen folder with the files in it and run the .cmd ??

    Thanks though...

    off to try it..
     
  6. Tito

    Tito Super Mod / Adviser
    Staff Member

    Nov 30, 2009
    17,372
    15,018
    340
    That means current folder...
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,601
    227
    60
    ok..


    found this bit of script and it sort of works

    What it needed though was for the makecab.exe to be in the same folder as the .cmd file.
    This then did sort of work and made all the files in C:\XP\1 into files with the ext "._",compressed.

    So what do you make of that code ?

    How would I change it then so the compressed files ended up into the folder of my choice ?

    I dont confess to know what %%a means....

    cheers..
     
  8. Tito

    Tito Super Mod / Adviser
    Staff Member

    Nov 30, 2009
    17,372
    15,018
    340
    I'm novice too in scripting :(
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,601
    227
    60
    Better at than me i bet......

    Thanks for the help though... :cool:

    Hopefull a scripting expert will spot this thread and give some pointers..
     
  10. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    5,873
    20,135
    180
    #10 Alphawaves, Jul 2, 2012
    Last edited by a moderator: Apr 20, 2017
    Use the /L switch to save to location you want ie:
    Code:
    cd %~dp0 & for %%a in (*.*) do makecab %%a /L "Save to location" >nul
    Not tried it but it should work. :eek:

    Command prompt > makecab /? for list of switches

    Cabpack is a useful tool
    http://www.larshederer.homepage.t-online.de/cabpack.htm
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,601
    227
    60
    #11 tnx, Jul 2, 2012
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Thanks Alphawaves..

    Time getting too close for work so i will look at this closer tomorrow arfo when I arise..

    If my memory serves me well,I believe you once helped me out a good while back now..

    Thanks for the info...
     
  12. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    5,873
    20,135
    180
  13. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,601
    227
    60
    Well I do believe I have got,I would say 90% of what I want..

    Let me go through it.

    I made a folder in C: called "Makecab"
    In here I have the makecab.exe
    Two folders, "Files" and "Compressed"
    I have my little .cmd with this script

    So with a little digging on the net from the other day and help from here it is doing what I want.

    Put the original driver files into "Files" run the .cmd and ALL the files are compressed and end up in "Compressed"

    @Alpahawaves..

    Thanks once again. I took the last part of your script and married it to the begining of what I had and voila.
    two things though,

    "CD" at the satrt of your code and ">nul" at the end,what were these doing ?

    I like how leaving >nul out and leaving the pause in I can clearly see it has worked.

    Cheers... :worthy:

    @Tito..

    Thanks mate ;)

    It makes me wonder now. Could I be clever enough to make some sort of GUI where a user could navigate to and folder holding the driver files and then select any folder or have it make a new folder containing the compressed files..

    mmmmmmmmmmmmmmmm......May just look into this. i have messed with IndigoRose AutoPlay media in the past. it may help..

    Cheers guys.....
     
  14. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,601
    227
    60
    Been testing it and it is working like a charm...Love it..

    Also thought I would add a "Clear Folders" .cmd file. One click and the files are deleted.

    Works pretty well too. cant make up my mind if I like having the pause in or not...No big deal.

    :biggrin:
     
  15. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,601
    227
    60
    Now i just can't stop my self.

    I have made another little .cmd file when placed inside a folder containing all the files I want to be copied to "Makecab" \nd run all the files are copied over,no navigating to be done..

    It sort of works apart from one major fault,it copies it's self too. I do not want this.

    So can i ask how do you amend the code to tell it not to copy it's self.
    the .cmd file name is
    maybe to go one setp further to delete it's self as well...Ohh can that be done....

    OMG...Nar hate text talk....OH MY GOD..

    Right I have made a few different .cmd's to do various tasks. Can all these be combined into just one .cmd so when it's run all the tasks are done.....ohh sounds tricky...

    :confused:
     
  16. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,601
    227
    60
    Well been messing,even more and now I have this script

    I like it..

    I put my "Copy Files to makecab.cmd" into the folder with the files I want to compress. Run the .cmd. It copies all the files to Makecab\Files but does not copy it's self.
    It then opens the folder Makecab and deletes its self from the original driver folder I put it in.
    i run the "Makecab.cmd" and all the files are compressed and end up in Makecab\Compressed.

    Quite pleased with my self to ne honest...:cool:
     
  17. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    5,873
    20,135
    180
    #17 Alphawaves, Jul 3, 2012
    Last edited by a moderator: Apr 20, 2017
    Cool glad you got it sorted :)

    One thing tho i dont think you need to add the attributes to the .cmd file as xcopy will not copy a .cmd file in use (.bat will do tho) ie:

    Code:
    @echo off
    cd /d %~dp0 & xcopy /y /w . C:\Makecab\Files
    pause
    explorer "C:\Makecab\Files"
    del "%~f0" && exit
    Also del "%~f0" && exit may work better in a .bat file :eek:

    EDIT

    Sorry i missed your previous comment:

    >nul = hides current output
    cd %~dp0 = Sets your current directory to the directory you have the .cmd/makecab/xcopy file in etc..

    :)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  18. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,601
    227
    60
    Cheers for that info Alphawaves....

    Will look at your codes properly later on. just on the old lappy right now.

    :D
     
  19. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,601
    227
    60
    #19 tnx, Jul 4, 2012
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Hi ya..

    I save your new code as a .bat and a .cmd They both copy themselves into the "Files" folder...

    It has me thinking though how I could make things simpler..mmmmmmmm
     
  20. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    5,873
    20,135
    180
    #20 Alphawaves, Jul 4, 2012
    Last edited by a moderator: Apr 20, 2017
    How about putting all files apart from batch file into a folder inside your working folder.
    .bat:
    Code:
    @echo off
    cd /d %~dp0 & xcopy /y /w Myfolder\. C:\Makecab\Files
    pause
    explorer "C:\Makecab\Files"
    del "%~f0" && exit
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...