Solved

Adding multiple files with similar names into a single zip folder

Posted on 2006-11-01
12
285 Views
Last Modified: 2011-09-20
I have a lot of files with the same name but different extentions i.e.

b.txt
b.tx_
c.txt
c.tx_
d.txt
d.tx_

I need to have them zipped into a zip file with only the first part of the file name i.e.

b.zip
c.zip
d.zip
etc...

Does anyone know how to automate this?  I have about 5000 files I need to do this for!
0
Comment
Question by:makman111
  • 7
  • 5
12 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 17852937
perl -e '@F{map/([^.]+)/,<*.*>}=(); system "zip $_ $_.*" for keys %F'
0
 

Author Comment

by:makman111
ID: 17852960
I get...

'zip' is not recognized as an internal or external command, operable program or batch file.

0
 

Author Comment

by:makman111
ID: 17852972
BTW:  This is a XP machine.
0
 
LVL 84

Expert Comment

by:ozo
ID: 17853011
What is the command for ziping b.txt and b.tx_ into b.zip on your XP machine?

perl -e "@F{map/([^.]+)/,<*.*>}=(); system qq'zip $_ $_.*' for keys %F"
0
 

Author Comment

by:makman111
ID: 17853051
do you mean what is the command line for creating a zip?
0
 

Author Comment

by:makman111
ID: 17853084
rar a <output filename> <input file 1> <input file2> <input file n>

i.e.

rar a a.zip a.txt a.tx_
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 84

Expert Comment

by:ozo
ID: 17853181
perl -e "@F{map/([^.]+)/,<*.*>}=(); system qq'rar a $_ $_.zip $_.*' for keys %F"
0
 

Author Comment

by:makman111
ID: 17853238
Close - but I think the parameters are being imported wrong.

It should be:

wzzip <output name> <file 1> <file 2> -> wzzip a.zip a.txt a.tx_

Is there a way I can see what is being sent to the wzzip application?
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 17853277
perl -e "@F{map/([^.]+)/,<*.*>}=(); print qq'wzzip  $_ $_.zip $_.*\n' for keys %F"
0
 

Author Comment

by:makman111
ID: 17853319
How do I put the file name in quotes - that is the trick.
0
 

Author Comment

by:makman111
ID: 17853327
perl -e "@F{map/([^.]+)/,<*.*>}=(); system qq'wzzip \"$_.zip\" \"$_.*\"' for keys %F"

Does this trick Thanks!!!!!!!!!!
0
 
LVL 84

Expert Comment

by:ozo
ID: 17853334
perl -e "push @{$F{(/([^.]+)/)[0]}},$_ for grep !/\.zip$/,<*.*>; print qq'wzzip $_.zip @{$F{$_}}\n' for keys %F"
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Many people tend to confuse the function of a virus with the one of adware, this misunderstanding of the basic of what each software is and how it operates causes users and organizations to take the wrong security measures that would protect them ag…
Windows 7 does not have the best desktop search built in. This is something Windows 7 users have struggled with. You type something in, and your search results don’t always match what you are looking for, or it doesn’t actually work at all. There ar…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now