Page 1 of 1

help! how to compress file

Posted: 28 Apr 2020 04:31
by luckejuin
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

Re: help! how to compress file

Posted: 28 Apr 2020 09:42
by ShadowThief
%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

Posted: 19 May 2020 22:17
by scavenger
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%