7zip CLI: specify target filename on extract
Asked Answered
H

2

6

I'm trying in the last 4 hours to do something that sounds simple :) Can I (any how) set the target file in the 7za command? (I need to rename the target filename, and add .bak to its extension)

Here is the command right now:

7za e -bd -y -o"target_folder" "source_folder" "filename"

so, same filename will be on target here.

Thank you.

Hallsy answered 14/12, 2016 at 13:56 Comment(1)
Unbelievable that this isn't possible to do in 2024, it's basically a requirement for using 7Z programmatically as part of a Bash script.Arjuna
F
4

if you are certain there is only one file in the archive, you can do the following:

7za e "c:\data\compressed_file.gz" -so > "c:\data\destination_file_name.txt.bak"

I have not attempted working with an archive with multiple files.

Folkways answered 13/7, 2020 at 18:7 Comment(0)
T
0

Try this:

7za e "source.zip" -o"target_folder"

Please note 'target_folder' could contain the folder name you want. And seems you switched 'Source' and 'Target'

For example:

7za e 123.zip -oc:\456

And for now, as far as I know, there is no way to modify each filename in the target folder. Folder name only.

Tirpitz answered 14/12, 2016 at 14:20 Comment(3)
Hi, first, this script is working, so the order is not matter if you set -o before the target folder, and, of course, I know that target_folder should contain the folder target name :) I need to change the filename, and not the folder. Thanks.Hallsy
Ok,then unfortunately, I do not think it is doable for 7zip commands. May I know where did you try to use that 7zip command? Probably you could use C# code to rename each unzipped files right after you extract it.Tirpitz
Sure, I used it with php, to extract files from 7z, the thing is, windows (or anti virus etc..) locking for a ~minute every .exe file I'm extracting, then I can not rename\copy with php, thats why I need it to be extracted with a different extension, Thank you for your help!Hallsy

© 2022 - 2024 — McMap. All rights reserved.