Solved

Adding multiple files with similar names into a single zip folder

Posted on 2006-11-01
12
286 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
#Citrix #POC #XenDesktop #vCenter #VMware #ESX
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.

863 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

23 Experts available now in Live!

Get 1:1 Help Now