1.

Solve : once compressed, redirect compressed file to another command line?

Answer»

Hi,

under windows 7, i created a bat file including several command lines.

my first command line compress a folder (using 7-zip) to a tar file (this works great)
my second command line should:
a. wait that folder is compressed to a file
b. take the compressed file (content of compressed folder) and inject it / redirect it to a command line (this new command line should compress to gzip format)

my main problem it's :
1. i don't know how to tell 2nd commandline to wait till folder is FINALLY compressed.
2. how to redirect (without typing the filename of compressed folder) the new compressed archive to new command line ?

i tried to understand how <& works but i'm not sure this is what i need

could you help me please ?
thxFirst you need to show the actual code you created.

One question. Why are you compressing twice?
Because unfortunatelly 7-zip doesn't allow to CREATE a tar.gzip file in 1 shot... and i need to create such file extension...not only tar, not only gzip but like under linux...tar.gzipDid you see the first part of my post?
You could CALL 7-zip using START /WAIT or you could use the free IZarcCC which does it all at once (well, it creates the tar and then gzips it but you only use one command)

Installer http://www.izarc.org/download/IZArcCL.exe

Website http://www.izarc.org/index.html

(This is the "Command Line Add-on" I am using.)

Auto-it is a folder containing a mixture of text files and .exe files total 4,796,368 bytes

C:\test>"C:\Program Files (x86)\IZArc\IZARCC.exe" -a -r -cx "C:\Archives\Auto-it.tgz" Auto-it

-cx is max compression

01/04/2013 20:47 3,429,444 Auto-it.tgz

Can just make a tar file:

C:\test>"C:\Program Files (x86)\IZArc\IZARCC.exe" -a -r "C:\Archives\Auto-it.tar" Auto-it

01/04/2013 20:50 4,843,520 Auto-it.tar

It needs the full PATH for the archive file or else it makes it in the program folder. Note the program path will be different on 32 bit Windows. You can change the .tgz extension afterwards. If you supply .tar.gz on the command line when running it makes filename.tar.tgz






I have learned from past experience that some programs just dont obey the wait option.
Batch files are sequential. Dont use the start command to run 7zip. Quote from: Squashman on April 01, 2013, 02:06:05 PM

I have learned from past experience that some programs just dont obey the wait option.
Batch files are sequential. Dont use the start command to run zip.

Command line exectutables don't need the start command. Anyhow, from a batch file he should be using the 7-Zip command line executable, 7za.exe. This returns only when the compression/archiving task is done. It's at 7-zip.org.

personally i already use auto-it and even if it is a good software, i agree that some applications do not respond to wait...
but more than that i don't want to use any artefact or extra software for that...i know because i already saw it on web that it is possible without that solution.

for example my first command like could be:
"c:\Program Files\7-Zip\7z.exe" a -r -mx9 -ttar my_archive my_folder_to_compress/*.*

and the 2nd command line should be in this case:
"c:\Program Files\7-Zip\7z.exe" a -r -mx9 -tgzip my_archive my_archive.tar
Auto-it is just an example folder I used.

I don't think you understood what I wrote.

If you don't want to use "extra software", why are you using 7-zip?

Why don't you use the 7-zip command line version 7za.exe? This would avoid all your problems.

Is English not your first language? (LA langue des rosbifs n'est pas ta langue maternelle ?)



I use 7z.exe and it works to pass the command to the archiver and wait for the file to be created.

This should work.

Code: [Select]@echo off
set "file=My_Archive"
"c:\Program Files\7-Zip\7z.exe" a -r -mx9 -ttar "%file%.tar" "my_folder_to_compress\*"
"c:\Program Files\7-Zip\7z.exe" a -r -mx9 -tgzip "%file%.tgz" "%file%.tar"Quote from: foxidrive on April 01, 2013, 03:45:16 PM
This should work.

This did work, both in a batch (7-zip did not return until each task was complete) and also when entered at the prompt...

Note: my Windows is 64 bit, so it installs 32 bit programs under C:\Program Files (x86)\. On a 32 bit system the install will be under C:\Program Files\

U:\Pan2>dir doctest
Volume in drive U is USB-U
Volume Serial Number is 70B2-B275

Directory of U:\Pan2\doctest

02/04/2013 18:53 <DIR> .
02/04/2013 18:53 <DIR> ..
14/02/2003 11:17 11,776 aseptic01.doc
14/02/2003 11:17 11,776 aseptic02.doc
14/02/2003 11:17 11,776 aseptic03.doc
14/02/2003 11:17 11,776 aseptic04.doc
14/02/2003 11:17 11,776 aseptic05.doc
14/02/2003 11:17 11,776 aseptic06.doc
14/02/2003 11:17 11,776 aseptic07.doc
14/02/2003 11:17 11,776 aseptic08.doc
14/02/2003 11:17 11,776 aseptic09.doc
14/02/2003 11:17 11,776 aseptic10.doc
10 File(s) 117,760 bytes
2 Dir(s) 318,992,576,512 bytes free


U:\Pan2>"C:\Program Files (x86)\7-Zip\7z.exe" a -r -mx9 -ttar "Doctest.tar" "Doctest\*"

7-Zip 4.65 Copyright (c) 1999-2009 Igor Pavlov 2009-02-03
Scanning

Creating archive Doctest.tar

Compressing Doctest\aseptic01.doc
Compressing Doctest\aseptic02.doc
Compressing Doctest\aseptic03.doc
Compressing Doctest\aseptic04.doc
Compressing Doctest\aseptic05.doc
Compressing Doctest\aseptic06.doc
Compressing Doctest\aseptic07.doc
Compressing Doctest\aseptic08.doc
Compressing Doctest\aseptic09.doc
Compressing Doctest\aseptic10.doc

Everything is Ok

U:\Pan2>"C:\Program Files (x86)\7-Zip\7z.exe" a -r -mx9 -tgzip "Doctest.tgz" "Doctest.tar"

7-Zip 4.65 Copyright (c) 1999-2009 Igor Pavlov 2009-02-03
Scanning

Creating archive Doctest.tgz

Compressing Doctest.tar

Everything is Ok

U:\Pan2>dir doctest*
Volume in drive U is USB-U
Volume Serial Number is 70B2-B275

Directory of U:\Pan2

02/04/2013 18:53 <DIR> Doctest
02/04/2013 18:54 123,904 Doctest.tar
02/04/2013 18:55 2,654 Doctest.tgz
2 File(s) 126,558 bytes
1 Dir(s) 318,992,576,512 bytes free



Discussion

No Comment Found