Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch file to unzip files onto another drive  (Read 3251 times)

0 Members and 1 Guest are viewing this topic.

RoscoePColtrane

    Topic Starter


    Newbie

    • Experience: Experienced
    • OS: Other
    Batch file to unzip files onto another drive
    « on: November 01, 2018, 01:39:33 PM »
    Hello,

    My 7z zip is installed on C:\Program Files\7-zip, but I need to unzip a file on E:\.  I've added the 7z path to environment variables, but no go.  Here's my bat file:

    @echo off
    SET "SOURCE=%E:\WWtesting\Source%":
    SET "TARGET=%E:\WWtesting\Target%":

    for %%I in ("%SOURCE%\*.zip") do (
      "%C:\Program Files\7-Zip\7z.exe" x -y -o"%TARGET%\" "%%I"
    )

    How do I get the bat file to run 7z from C: and unzip it on E:?

    Squashman



      Specialist
    • Thanked: 134
    • Experience: Experienced
    • OS: Other
    Re: Batch file to unzip files onto another drive
    « Reply #1 on: November 01, 2018, 03:27:19 PM »
    No clue where you found syntax for using percent symbols and colons like that.

    Code: [Select]
    @echo off
    SET "SOURCE=E:\WWtesting\Source"
    SET "TARGET=E:\WWtesting\Target"

    for %%I in ("%SOURCE%\*.zip") do (
      "C:\Program Files\7-Zip\7z.exe" x "%%I" -y -o "%TARGET%\"
    )

    patio

    • Moderator


    • Genius
    • Maud' Dib
    • Thanked: 1769
      • Yes
    • Experience: Beginner
    • OS: Windows 7
    Re: Batch file to unzip files onto another drive
    « Reply #2 on: November 01, 2018, 05:30:34 PM »
    Howdy Squash...all good on yer end ? ?
    " Anyone who goes to a psychiatrist should have his head examined. "

    Squashman



      Specialist
    • Thanked: 134
    • Experience: Experienced
    • OS: Other
    Re: Batch file to unzip files onto another drive
    « Reply #3 on: November 01, 2018, 08:49:32 PM »
    Howdy Squash...all good on yer end ? ?
    Yeah, but I will probably throw a few back a few this weekend in honor of Foxidrive who passed away two years ago this Saturday.

    patio

    • Moderator


    • Genius
    • Maud' Dib
    • Thanked: 1769
      • Yes
    • Experience: Beginner
    • OS: Windows 7
    Re: Batch file to unzip files onto another drive
    « Reply #4 on: November 02, 2018, 04:24:49 AM »
    He is missed...
    " Anyone who goes to a psychiatrist should have his head examined. "

    DaveLembke



      Sage
    • Thanked: 662
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Batch file to unzip files onto another drive
    « Reply #5 on: November 02, 2018, 03:03:00 PM »
    He is missed and the help he gave still lives on in scripts etc that he assisted with. At work one such script he surprised me with his creativity in a system that cant have any software brought in on media and so limited to what ever you can do from command shell and notepad in NT4 environment on an old Pentium III 700Mhz and the script he helped greatly with creates a QBasic (.BAS file ) dynamically through batch and then it calls to execute this QBasic program to do what was beyond what batch can do alone.

    We run this batch file that dynamically creates the QBasic programs to run through iterations for all files with specific file extensions at a target directory once a week and it saves from having to manually change text files that are used for machine configurations. It use to be 30 minutes to manually edit in notepad about 50 text files to switch a parameter within the text files from "N" to "Y".

    This script he gave me saves us about 2 hours a month not having to manually edit text files and we have been running it for about 2 years now. What use to take about 30 minutes manually is completed in 10 seconds every sunday morning after the machine gets its weekly configuration updates passed down to it from another system where a site controller isn't able to make the N to Y change and engineering simply stated why don't we just manually edit the config files for changing N to Y ... But engineering wasn't going to add a button with a function to do that from the site controller software. But Foxidrive gave me the ability to manually type the batch files on that system and create them which was within the rules of what I could and couldn't do from my boss, since I was told I can do any coding as long as nothing is brought in on CD, Floppy, or other media due to system security concerns where they don't want any virus etc coming in from the outside, however whatever you can manually type and save as a .bat file extension in the system is fair game.  ;D

    patio

    • Moderator


    • Genius
    • Maud' Dib
    • Thanked: 1769
      • Yes
    • Experience: Beginner
    • OS: Windows 7
    Re: Batch file to unzip files onto another drive
    « Reply #6 on: November 02, 2018, 04:17:40 PM »
    Let's all tilt one for him this weekend...

    He would just laff...
    " Anyone who goes to a psychiatrist should have his head examined. "