Solved

Adding multiple files with similar names into a single zip folder

Posted on 2006-11-01
12
290 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
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
 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a recent article here at Experts Exchange (http://www.experts-exchange.com/articles/18880/PaperPort-14-in-Windows-10-A-First-Look.html), I discussed my nine-month sandbox testing of the Windows 10 Technical Preview, specifically with respect to r…
I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

726 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