hello,
I want to compress a specific folder and togerther with a file..
let's say I'm gonna zip a file
ex.
in my desktop i have this structure
inside my compress folder I have this
Fruits
- Folder A
- a.txt
- b.txt
- Folder B
- a.txt
-b.txt
a.bin
b.bin
c.bin
I want to zip Fruits folder + b.bin into a one zip file ex.hellow.zip
then delete Fruits folder and b.bin
I think I get what I want but the problem I can't delete the Fruit folder and it's sub folder
@echo off
:compress
set path=Fruits
set path2=b.bin
set z=compressed.zip
7z.exe a -tzip compressed.zip "%path%"
7z.exe a -tzip compressed. zip "%path2%"
if exist "%path%" (
for /d %%p in ("%path%"\*.*") do rmdir "%%p" /s /Q
del /s /q %path%\*.*
thank you
help! how to compress file
Moderator: DosItHelp
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: help! how to compress file
%PATH% is a system variable and it holds the location of every important file on your computer. Please don't overwrite that value and definitely don't delete anything from it.
Re: help! how to compress file
using your variables,
Code: Select all
@echo off
:compress
set folder=Fruits
set file=b.bin
set z=compressed.zip
7z.exe a %z% %folder% %file%
if %ERRORLEVEL% EQU 0 rd /s /q %folder% & del /q %file%