topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 11:41 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA - Compress files with 7zip without the folder  (Read 14392 times)

rookie1

  • Participant
  • Joined in 2008
  • *
  • default avatar
  • Posts: 5
    • View Profile
    • Donate to Member
IDEA - Compress files with 7zip without the folder
« on: November 15, 2008, 01:39 PM »
Hello,

I've been trying to compress all the files in a particular folder via command line.
There are about 50 files in the folder, I would like all the files from that folder to be compressed in to one 7zip, but without the folder.
As in, if you decompress it on your desktop, you would have a mess :). That's what I'm looking for.
So far I've come up with:

code:
7za.exe a all_files.7z all_files\*

But if I do it like this, it will include the folder, so I get a compressed folder and not 50 seperate files that are being compressed.

I've been looking all over, but couldn't find anything about this. Help would be much appreciated.

Kind regards,

SirSmiley

  • Member
  • Joined in 2007
  • **
  • Posts: 64
    • View Profile
    • Donate to Member
Re: IDEA - Compress files with 7zip without the folder
« Reply #1 on: November 15, 2008, 02:32 PM »
Still getting my scripts organized but, did you try using *.*? I think that should get all the files without the folder.

rookie1

  • Participant
  • Joined in 2008
  • *
  • default avatar
  • Posts: 5
    • View Profile
    • Donate to Member
Re: IDEA - Compress files with 7zip without the folder
« Reply #2 on: November 15, 2008, 02:37 PM »
Thank you, I tried it but that doesn't seem to work.

I forgot to tell: there are also some folders inside the "all_files\" folder that must be packed with the 50 files together.

SirSmiley

  • Member
  • Joined in 2007
  • **
  • Posts: 64
    • View Profile
    • Donate to Member
Re: IDEA - Compress files with 7zip without the folder
« Reply #3 on: November 15, 2008, 03:55 PM »
You need to run the command line from within the folder.

Something like this

C:\all_files>7za.exe a all_files.7z -r *

rookie1

  • Participant
  • Joined in 2008
  • *
  • default avatar
  • Posts: 5
    • View Profile
    • Donate to Member
Re: IDEA - Compress files with 7zip without the folder
« Reply #4 on: November 15, 2008, 04:57 PM »
I'm sorry, I've tried it several ways whith your code but no luck...

Would it help if it is also fine when it's done whith makecab?

If they are all being cabbed together, it would be great to.

set cab=C:\prog\makecab
:cab_all_files
pause
%cab% /f C:\all_files\* c:\all_files.cab    (could not find file c:\all_files\*   or    *.*)
pause

Thank you for you're help
« Last Edit: November 15, 2008, 05:00 PM by rookie1 »

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA - Compress files with 7zip without the folder
« Reply #5 on: November 15, 2008, 11:33 PM »
i don't think there is such an option with 7z. here are the options from the command-line tool:
cmd-line options
7-Zip 4.40 beta  Copyright (c) 1999-2006 Igor Pavlov  2006-05-01

Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...]
       [<@listfiles...>]

<Commands>
  a: Add files to archive
  d: Delete files from archive
  e: Extract files from archive (without using directory names)
  l: List contents of archive
  t: Test integrity of archive
  u: Update files to archive
  x: eXtract files with full paths

<Switches>
  -ai[r[-|0]]{@listfile|!wildcard}: Include archives
  -ax[r[-|0]]{@listfile|!wildcard}: eXclude archives
  -bd: Disable percentage indicator
  -i[r[-|0]]{@listfile|!wildcard}: Include filenames
  -m{Parameters}: set compression Method
  -o{Directory}: set Output directory
  -p{Password}: set Password
  -r[-|0]: Recurse subdirectories
  -scs{UTF-8 | WIN | DOS}: set charset for list files
  -sfx[{name}]: Create SFX archive
  -si[{name}]: read data from stdin
  -slt: show technical information for l (List) command
  -so: write data to stdout
  -t{Type}: Set type of archive
  -v{Size}[b|k|m|g]: Create volumes
  -u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options
  -w[{path}]: assign Work directory. Empty path means a temporary directory
  -x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames
  -y: assume Yes on all queries


and an online example here.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Re: IDEA - Compress files with 7zip without the folder
« Reply #6 on: November 16, 2008, 02:12 AM »
IIUC, I had a similar difficulty trying to package a plugin for FARR.

What I ended up doing was to have an initial step of cd-ing in to the folder containing what I wanted to have compressed (as mentioned by SirSmiley) and also to have the resulting file created outside of the folder containing the contents to be compressed.  What follows is a sketch with some details.

If "test" is the name of the folder containing things to compress, the following is the sort of command line that worked for my case (assuming I run the command in the parent folder of "test"):

cd test && 7z.exe a -tzip ..\test.zip -r .\*

To verify the results, I used the Open menu item in the File menu of 7-zip File Manager on the test.zip file -- I also extracted the test.zip file using the "7-zip" -> "Extract Here" menu item from the Windows Explorer context menu successfully.  The version of 7-zip I am using appears to be 4.5.7.

I tried basically what SirSmiley mentioned w/ success too:

c:\test>7za.exe a test.7z -r *

The result was a test.7z file in my C:\test folder -- I also verified its contents using the two methods mentioned above.

rookie1

  • Participant
  • Joined in 2008
  • *
  • default avatar
  • Posts: 5
    • View Profile
    • Donate to Member
Re: IDEA - Compress files with 7zip without the folder
« Reply #7 on: November 16, 2008, 02:55 AM »
thank u SirSmiley, lanux128 and Ewemoa

im new to this and it is the last step of a larger  (fist time) script i am making

first it unpacks a 7z file in a folder, than it removes some files en than replace some files.

and than sould be packet again as it was.(a .cab would be fine to)

with Your information above i must get it write :-) i am going to work on it!

 i must stil be doing something wrong....

Kind regards

rookie1

  • Participant
  • Joined in 2008
  • *
  • default avatar
  • Posts: 5
    • View Profile
    • Donate to Member
Re: IDEA - Compress files with 7zip without the folder
« Reply #8 on: November 16, 2008, 03:19 AM »
Code:
cd test && 7z.exe a -tzip ..\test.zip -r .\*

worked great, Jippie I'm very happy now. :-D
But how do I specify where the 7za.exe file is located?

cd test && prog\7za.exe a -t7z ..\test\ -r .\*         is not working

edit: Good cd test && ..\prog\7za.exe a -t7z ..\test -r .\* Good   WORKS!!

the script must be used on a system where maybe there's no 7zip installed
In the mean time I'll keep searching, you already helped me a lot

Thanx Again


« Last Edit: November 16, 2008, 04:56 AM by rookie1 »