Tech Talk Discuss PC Hardware, Software, Internet and Other Technology

Is there a program to zip files like this?

Old 12-10-11, 06:36 PM
  #1  
DVD Talk Limited Edition
Thread Starter
 
namrfumot's Avatar
 
Join Date: May 2000
Posts: 6,409
Is there a program to zip files like this?

I have a folder with roughly 200 sets of files like this:

FILE1.mp3
FILE1.mpg
FILE2.mp3
FILE2.mpg

etc, etc....

I want to zip them all like this:

FILE1.zip
FILE2.zip

Creating, naming, and dragging all those files into new zips will take ages. Is there a program that does this?
namrfumot is offline  
Old 12-10-11, 11:27 PM
  #2  
DVD Talk Legend
 
Join Date: Apr 2002
Posts: 20,723
Re: Is there a program to zip files like this?

In windows explorer, arrange files by type (extension)?

You want file1.mp3 and file2.mp3 etc to go into the same zip?

Or you want file1.mp3 and file1.mpg to go into the same zip?

Either way (sort by filename or file ext), you can use 7-zip to right-click to send selected files to zip. Shouldn't take too much time.
Ranger is offline  
Old 12-10-11, 11:46 PM
  #3  
DVD Talk Special Edition
 
Join Date: Sep 1999
Location: Orlando, FL
Posts: 1,741
Re: Is there a program to zip files like this?

Note, zipping already highly compressed media doesn't usually yield much reduction in file size.
Kevin M. Dean is offline  
Old 12-12-11, 10:02 AM
  #4  
lxl
Senior Member
 
Join Date: Jun 1999
Location: San Jose, CA
Posts: 813
Re: Is there a program to zip files like this?

7zip has a command-line version
http://downloads.sourceforge.net/sevenzip/7za920.zip

You can use 7za.exe with various switches to suit your need.

7za.exe also supports copy mode(meaning when you zip files you just "copy", not "compress" files into zip archive, "copy" is much faster than "compress").
lxl is offline  
Old 12-12-11, 05:00 PM
  #5  
DVD Talk Limited Edition
Thread Starter
 
namrfumot's Avatar
 
Join Date: May 2000
Posts: 6,409
Re: Is there a program to zip files like this?

I cant find a quick way (using 7 zip) to create a zip named after the file I am zipping. It always tries to create the zip named after the folder the file is in!?
namrfumot is offline  
Old 12-12-11, 05:26 PM
  #6  
DVD Talk Special Edition
 
Join Date: Sep 2000
Location: Charlotte, NC
Posts: 1,659
Re: Is there a program to zip files like this?

I know the command-line version of WinRAR supports wildcards for creating file names. I'm sure 7-Zip has something similar.
Rex Fenestrarum is offline  
Old 12-12-11, 08:24 PM
  #7  
DVD Talk Special Edition
 
Join Date: Mar 2002
Posts: 1,991
Re: Is there a program to zip files like this?

Out of idle curiosity, just why do you need to do this? To save space on a hard drive? I'd recommend getting a larger drive.

As Kevin Dean mentioned, zipping already compressed files won't get you much. I can't speak for mp3 files, but I know from experience that trying to compress certain other files (particularly Photoshop and PDF files) are a waste of time. You end up with only 2 or 3% space savings.
Jon2 is offline  
Old 12-12-11, 09:51 PM
  #8  
DVD Talk Limited Edition
Thread Starter
 
namrfumot's Avatar
 
Join Date: May 2000
Posts: 6,409
Re: Is there a program to zip files like this?

Well it's for karaoke...each song has an .mp3 and a .cdg resulting in hundreds and hundreds of files - my karaoke program reads zip files. So rather than have hundreds of files I can have half the number and keep it better organized.

Not for compression at all
namrfumot is offline  
Old 12-12-11, 10:25 PM
  #9  
DVD Talk Legend
 
Join Date: Apr 2003
Location: Land of the Lobstrosities
Posts: 10,300
Re: Is there a program to zip files like this?

Originally Posted by namrfumot View Post
I cant find a quick way (using 7 zip) to create a zip named after the file I am zipping. It always tries to create the zip named after the folder the file is in!?
If you select one file it will name it after that file. If you select multiple files it will name it after the folder they are in.

Here's a single line command that will do what you want, but I I would test it with a small batch first.

FOR %i in (*.*) do start /wait 7za a %~ni.zip %i

Here's what it does:

FOR %i in (*.*) ...

For every file in the is directory. You can change the file selection to " (*.mp3 *.txt *.jpg) " using that syntax, if you only want some types.

do start /wait 7za ...

Run the 7za commandline .exe, put the exe in the folder, your win path, or add the path to the command. /wait tells program to wait until it finishes before starting the next instance, otherwise it would try to launch the program for every file all at once.

a %~ni.zip %i

These are 7zip arguments. a = add/create, %~ni is the filename minus extension and %i is the file name. So it's saying Add to archive filename.zip the file filename.whatever
wmansir is offline  
Old 12-13-11, 01:39 PM
  #10  
DVD Talk Legend
 
Join Date: Oct 2001
Posts: 17,661
Re: Is there a program to zip files like this?

Originally Posted by wmansir View Post
Here's a single line command that will do what you want, but I I would test it with a small batch first.

FOR %i in (*.*) do start /wait 7za a %~ni.zip %i
I tested this, but modified the command a bit:
FOR %i in (*.cdg) do start /wait 7z a -tZip %~ni.zip %i %~ni.mp3
I combined the zipping of the .cdg and .mp3 files into one line. I used *.cdg as the wildcard so that for every .cdg file it finds, it also adds a .mp3 file of the same name to the zip of the same name.

The result is that for:

TEST.mp3
TEST.cdg

both ended up in zip file:

TEST.zip

For my test, I created TEST.mp3 and TEST.cdg and ran the command, which created TEST.zip with the two previous files inside.
Jay G. is offline  
Old 12-13-11, 04:10 PM
  #11  
DVD Talk Limited Edition
Thread Starter
 
namrfumot's Avatar
 
Join Date: May 2000
Posts: 6,409
Re: Is there a program to zip files like this?

Im trying to run the 7zip command line 7za.exe, but the window just pops up and disappears everytime. It never gives me the chance to enter anything!?
namrfumot is offline  
Old 12-13-11, 04:45 PM
  #12  
DVD Talk Legend
 
Join Date: Oct 2001
Posts: 17,661
Re: Is there a program to zip files like this?

Originally Posted by namrfumot View Post
Im trying to run the 7zip command line 7za.exe, but the window just pops up and disappears everytime. It never gives me the chance to enter anything!?
You have to open command prompt from the start menu.

Then, once the command prompt is open, navigate to the desired folder using the "cd" command.
http://www.sophos.com/support/knowle...cle/13195.html

Once in the right folder, you can run the command that either I or wmansir gave.
Jay G. is offline  
Old 12-13-11, 06:05 PM
  #13  
DVD Talk Limited Edition
Thread Starter
 
namrfumot's Avatar
 
Join Date: May 2000
Posts: 6,409
Re: Is there a program to zip files like this?

Omg I havent seen DOS in like 20 years haha. Ok so I went to the folder: F:/Karaoke and typed in the command line: FOR %i in (*.cdg) do start /wait 7za -tZip %~ni.zip %i %~ni.mp3

The screen went nuts, a bunch of windows blinked up, (it looked to be working) and command prompt gave me a ton a lines like this:

F:\Karaoke\start /wait 7za -tZip SF305-15 - Coldplay - Every
Teardrop Is A Waterfall.zip SF305-15 - Coldplay - Every Teardrop Is A Waterfall
.cdg SF305-15 - Coldplay - Every Teardrop Is A Waterfall.mp3


But I don't see any zips? Yes I suck...
namrfumot is offline  
Old 12-13-11, 06:34 PM
  #14  
DVD Talk Legend
 
Join Date: Apr 2003
Location: Land of the Lobstrosities
Posts: 10,300
Re: Is there a program to zip files like this?

You might want to try adding "" to the file names:

FOR %i in (*.cdg) DO start /wait 7za a -tZip "%~ni.zip" "%i" "%~ni.mp3"
wmansir is offline  
Old 12-13-11, 06:47 PM
  #15  
DVD Talk Limited Edition
Thread Starter
 
namrfumot's Avatar
 
Join Date: May 2000
Posts: 6,409
Re: Is there a program to zip files like this?

That did it
namrfumot is offline  
Old 12-13-11, 06:51 PM
  #16  
DVD Talk Limited Edition
Thread Starter
 
namrfumot's Avatar
 
Join Date: May 2000
Posts: 6,409
Re: Is there a program to zip files like this?

Nowwww...is there a way to have 7zip search subfolders and do the same thing?
namrfumot is offline  
Old 12-13-11, 07:55 PM
  #17  
DVD Talk Legend
 
Join Date: Apr 2003
Location: Land of the Lobstrosities
Posts: 10,300
Re: Is there a program to zip files like this?

It's easy to make it recursive, just change it to

FOR /R %i ....

You may also have to change any instance of %~ni to %~dpni and %i to %~fi

That will send 7z the full path name instead of just the file name.

And/or you may also have to give the full path the 7za.exe. It depends on what context the batch file executes the command. In other words, will it try to run each command from the root folder, or start 7z in each subfolder. If you give the full path names of the .exe and give 7z the full path for each file it doesn't matter.
wmansir is offline  
Old 12-13-11, 08:10 PM
  #18  
DVD Talk Limited Edition
Thread Starter
 
namrfumot's Avatar
 
Join Date: May 2000
Posts: 6,409
Re: Is there a program to zip files like this?

Hmm....I tried:

FOR /R %i in (*.cdg) DO start /wait 7za a -tZip "%~ni.zip" "%i" "%~ni.mp3" and it went through all the subfolders and created zips with the .cdg files only. It said it couldn't find the other file (mp3).

I then tried what you said:
FOR /R %~fi in (*.cdg) DO start /wait 7za a -tZip "%~dpi%ni.zip" "%~fi" "%~dpi%ni.mp3"

and it said "%~fi was unexpected at this time"

Last edited by namrfumot; 12-13-11 at 08:16 PM.
namrfumot is offline  
Old 12-13-11, 08:17 PM
  #19  
DVD Talk Legend
 
Join Date: Apr 2003
Location: Land of the Lobstrosities
Posts: 10,300
Re: Is there a program to zip files like this?

I had a typo. It should have been %~dpi%~ni but i realized that you can combine it to just %~dpni
wmansir is offline  
Old 12-13-11, 08:40 PM
  #20  
DVD Talk Limited Edition
Thread Starter
 
namrfumot's Avatar
 
Join Date: May 2000
Posts: 6,409
Re: Is there a program to zip files like this?

How the heck did you learn this stuff??
namrfumot is offline  
Old 12-13-11, 09:49 PM
  #21  
DVD Talk Legend
 
Join Date: Apr 2003
Location: Land of the Lobstrosities
Posts: 10,300
Re: Is there a program to zip files like this?

Mostly google for this because I'm not that familiar with DOS programming commands. From knowing other languages I knew what needed to be done and the common name for the command (For Each), so I just needed google to get the syntax for DOS's version of the command and how to manipulate the variable containing the filename.
wmansir is offline  
Old 12-13-11, 09:59 PM
  #22  
DVD Talk Limited Edition
Thread Starter
 
namrfumot's Avatar
 
Join Date: May 2000
Posts: 6,409
Re: Is there a program to zip files like this?

My brain salutes you!
namrfumot is offline  

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Thread Tools
Search this Thread

Archive Advertising Cookie Policy Privacy Statement Terms of Service

Copyright 2018 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.