MAKECAB - Multiple driver files to compress

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

  1. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,643
    247
    60
    #21 tnx, Jul 4, 2012
    Last edited: Jul 4, 2012
    (OP)
    I had an idea to try ans simplify things...

    Instead of copying all the files from their current locations I could write a new script,put that into my chosen directory run it.
    What is does is makes a new folder, "Compressed" then compresses the files into that folder.

    i will probebly have to copy the makecab.exe there as well but as earlier the .bat\.cmd could easily delete the makecab.exe and it's self after the procces is finished.

    So with that in mind i wrote this

    The result...

    It works but not in some folders and I think I have worked out why I am having some problems....
    I test this on the Desktop it works
    In C: it works
    In E: it works ------ E = 1TB storage disc
    When I place the same .bat or .cmd file into where my drivers are kept something strange happens.

    I do NOT get the folder i wish to make, "Compressed" I get three quite random folders :-

    "Vista" + "Windows" + "XP"

    And I think the problem is my file structure on the "E" drive

    Here is where my folders are
    I think the long name is causing problems....I am not sure.

    Idea...
    make my self a new folder in E several folders deep but without "#1 etc" mmmm

    BUGGER ME.....Time to have a major overhaul of my E drive...

    I just tested this
    A folder on E five folders deep and I tested the make "Compressed" folder and it worked. This prooves my folder labeling system is rubbish. WHAT A FECKING IDIOT.
    I am mad with myself now...i have used this for some years now.....Bugger..

    Any how,not to bore you I will have to run along and test out some coding in the simpler folder srtucture..

    tut tut tut tut ( tn is shaking head from side to side )
     
  2. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,643
    247
    60
    OH MY GOD....

    @ Alphawaves.....

    I am lost for words....

    you gave me this a short while ago

    It did not work....... Read my last post for the reason.

    In my test layout
    I placed some driver files.
    Amended your code ever so slightly

    Man IT WORKS LIKE ADREAM.... LIKE A DREAM I TELL YOU !!!!!!!!!!

    No need to copy the damn makecab.exe into the chosen folder....

    And the reason it worked...Yes... My folder structure........Oh my god.....

    In the past I have had similar sort of problems but never figured it out.....

    Cheers Alphawaves.....:worthy:
     
  3. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,643
    247
    60
    You know by now you must be pissed of reading my post I throw up every time I think of summet or summet does not go the way I planned it..

    Well I have been sat here thinking about my folder structure. Well it might be a bit OTT but I like it and,yes I want to keep it..

    So

    I read the thread over and over.
    Looked at the codes I have over and over..

    the "CD" at the front of your coding suddenly hit me..."Change Directory"

    So i thought,yes lets try this in my folder structure

    It worked. In
    A new folder "Compressed" was made....

    All I have to do is add your makecab script and i am just about there....

    Thought of adding a couple mor things into the mix.

    make new folder "I386"
    copy all files from the newly compressedfolder "*sy_" into the I386 folder.

    This then sets things up very nicely to aid me in the reason I want to compress the drivers in the first place...

    Thanks for reading....If you stil are....:cool:
     
  4. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    6,181
    21,958
    210
    #24 Alphawaves, Jul 4, 2012
    Last edited by a moderator: Apr 20, 2017
    You are a busy guy tnx :D

    maybe something like this (nothing fancy)
    Code:
    @echo off && cd %~dp0 & md "Compressed" & md "I386" & for %%a in (*.*) do makecab %%a /L "Compressed"
    for %%a in (Compressed\*cm_) do del /q %%a & for %%f in (Compressed\*sy_) do copy /y %%f "I386"
    pause & explorer "I386" & exit
    :eek:
     
  5. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,643
    247
    60
    #25 tnx, Jul 5, 2012
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Hi ya. Just got in from work,sat here reading this new code. It's all blurrey and my brain has shut down. So I will look at this closer later on.

    Cheers mate.
     
  6. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,643
    247
    60
    #26 tnx, Jul 5, 2012
    Last edited by a moderator: Apr 20, 2017
    (OP)
    Hi ya...urrrrr...mmmmmmm..urrrrrrrr

    Well cheers mate buttttttt it works to a certain extent but not fully. It does not copy the .sy_ files to I386.......
    Upto that point it works great. i like the little delete .cmd from Compressed. ;)

    I just wish I could look at such codes and fully understand them..

    Can i ask what
    and
    ....Similar command but with a different switch....If thats the right terminology.

    Also can I ask does it matter if the script\code is split onto different lines or one long line ? For me it seems easier to understand if each command is on it's own line....Does that make sence ?

    I dont wanna take up more of your time mate. Sure you have lots of better things to do than help me out...You've helped loads already..Thanks....
     
  7. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,643
    247
    60
    been reading online about command\batch scripts and found summet regarding
    Thought this may be neater than delete the file after the event..
    Tried adding /exclude to a simple copy files from one folder to another and I cant seem to get it to work.

    Have you heard of this ?
     
  8. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    6,181
    21,958
    210
    #28 Alphawaves, Jul 5, 2012
    Last edited by a moderator: Apr 20, 2017
    Thats weird try this:
    Code:
    @echo off
    md "%~dp0Compressed" & md "%~dp0I386"
    for %%a in ("%~dp0*.*") do makecab %%a /l "%~dp0Compressed">nul
    for %%a in ("%~dp0Compressed\*cm_") do del /q %%a
    for %%a in ("%~dp0Compressed\*sy_") do copy /y %%a "%~dp0I386"
    pause
    explorer "%~dp0I386"
    exit
    With /exclude you need to create a txt file, say "exclusions.txt"

    cmd file:
    Code:
    xcopy "%~dp0*.*" "%~dp0I386" /Exclude:%~dp0exclusions.txt
    add the file name you want to exclude to exclusions.txt
    ie:
    Code:
    yourfile
    ;)
     
  9. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,643
    247
    60
    Well,the exclude seems more trouble than it's worth, simpler just to delete it as you have written.

    I do like the look of your latest script. Will try it out as soon as poss.

    Cheers.
     
  10. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,643
    247
    60
    Well.....I have just tested your new code. Mixed results...

    I have setup in C:\ a folder called "MAKECAB". This is where I have been testing all the various codes you have given me and my own concoctions.....

    Well when I test your lates code here it works like a charm.But when i test it in the old "E" drive folder structure it does not makecab nor copy any files ?

    What i think I may do is revert back to having the files copied to a folder on C:\ then makecab etc etc and so on...

    It must be down to the long name structure i have....you get a few folders in and the name becomes very long indeed...

    I will have to revert to copying the files to a folder on C:\ then use this new code.....

    Cheers matey...:)
     
  11. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    6,181
    21,958
    210
    If your old folder structure is not making cab nor copying, try adding the full path to makecab.exe and copy.exe. ;)
     
  12. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,643
    247
    60
    :biggrin::biggrin::biggrin::biggrin::
    I HAVE IT...

    File saved as "DriverCompressor.cmd"

    I copy this file into my chosen driver folder and run it.
    Two folders are made, "Compressed" and "I386".
    The driver files are compressed and put into "Compressed"
    The newly made .sy_ files are then copied into the newley made "I386" folder.

    i have tested this in my "E" drive and it works like a charm. tested it out on all my drivers,works every time...

    @ Alphawaves...

    Cheers fella for all your help. This latest code is based on yours but i found leaving out the "%~dp0" worked better.

    :biggrin:

    @Tito

    Thanks mate for helping out too.....:biggrin:

    Forums..Dont you just love them...

    :)
     
  13. Alphawaves

    Alphawaves Super Moderator/Developer
    Staff Member

    Aug 11, 2008
    6,181
    21,958
    210
    #33 Alphawaves, Jul 7, 2012
    Last edited: Jul 7, 2012
    Awesome, glad you got it working.. ;)

    Runs ok as admin ?