• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

help with 7za

Hmm.. I don't this is 100% what you were going for, but I *think* it'll work.

I did this with 7zr by they way... I think it's quite similar.

Code:
ls /your/dir | grep -v ".7z" | grep -v ".zip" > /tmp/out.1
7zr a arch1.7z @/tmp/out.1
I tried it a few ways before and I was getting the same error you were. I think it has to do with the brace expansion, but I'm not sure. This just creates a list file and then calls that list file.

Hope that helps. :)
 
Upvote 0
Shoot. Maybe 7za and 7zr are not as similar as I thought....

How is your archive directory set up? Is it all files in one directory - or are there multiple directories?

Hmm... What error are you getting? That same one with Incomplete command or whatever it said?

as a test I was doing ~/Downloads/temp I had a zip file in temp along with some other regular files everytime I do something similar to this

7za a temp.7z ~/Downloads/temp -x!*.zip
I get the error of it still zipping the zip file if i add the " r -x!" then i get incorrect command

IF I SHOOT IT THEN I GET A INCORRECT COMMAND WITH A CRACKED SCREEN.


@Early
Yeah I have done that I have done -ax I have put it up front of the commands, behind them and still get the same thing either it will make the archive adding the zip file or it gives me the incorrect command error.

Basically when I zip up the contents from my SDCARD in the phone I want to archive everthing except for the stuff that is already in archive format. no need to compress that stuff again. I guess I may have to go through and remove the zips before I run my bash to zip the sdcard up. I was going to put this in conjuction with my other bash that copies the entire content of the sdcards using adb command.
I was going to automate the process of compressing those backups and removing everything from the original except the archived files that were there. I could then rsync to an archived folder those files and then delete the source files and finally delete the empty directorys.

Sounds simple right???????
 
Upvote 0
From the man page -

-x[r[-|0]]]{@listfile|!wildcard}

So, doesn't !wildcard mean that no wildcards are allowed?

Maybe better to create a list of the files you want to exclude and then input that list?
I saw that, I didn't get it. But that makes sense (the ! and all).... what's the part with square brackets mean?

as a test I was doing ~/Downloads/temp I had a zip file in temp along with some other regular files everytime I do something similar to this

7za a temp.7z ~/Downloads/temp -x!*.zip
I get the error of it still zipping the zip file if i add the " r -x!" then i get incorrect command

IF I SHOOT IT THEN I GET A INCORRECT COMMAND WITH A CRACKED SCREEN.


@Early
Yeah I have done that I have done -ax I have put it up front of the commands, behind them and still get the same thing either it will make the archive adding the zip file or it gives me the incorrect command error.

Basically when I zip up the contents from my SDCARD in the phone I want to archive everthing except for the stuff that is already in archive format. no need to compress that stuff again. I guess I may have to go through and remove the zips before I run my bash to zip the sdcard up. I was going to put this in conjuction with my other bash that copies the entire content of the sdcards using adb command.
I was going to automate the process of compressing those backups and removing everything from the original except the archived files that were there. I could then rsync to an archived folder those files and then delete the source files and finally delete the empty directorys.

Sounds simple right???????
Hmm... I'd play around with that ls into grep I had up a few posts... that *should* be doing that.
When I tested it with 7zr, it would list the contents of my directory except anything with a zip or 7z file extension... and it would use that as the include list.
 
Upvote 0
Anything in brackets means optional and an exclamation mark means not.

{|} means use one or the other on either side of the bar. The {|} aren't part of the command sequence.

That's usually how those work.

argedion - can you use a script to add files to the archive in a loop provided their not already zips?

not sure i haven't done that before but i haven't done this before either so its all new to me. I will play around this weekend and see what I can come up with. I'll try using grep and make a list as 9to5 suggest.
 
Upvote 0
I'm going to finally have to learn sed and awk one of these days... ;)
Regular expressions are the answer to this without a doubt, and to learn sed and awk you need to know regular expressions.

It's been a while since I've written a script for 7za so the examples that I have may not be up to date. If not too much has changed, you should be able to pipe the output of something like `find' into 7za on the same command line. Something like :

find (args) | 7za a -t7z -mx=9 -mmt=on myfile.7z -

will pipe the stdout of find into stdin of 7za, eliminating the need for an intermediate file. Although I'm really rusty on find, I know it can do what you want because I've seen people do it that way.

Now let me see if my O'Reilly "Regular Expressions" book is reachable...
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones