Solved

Adding multiple files with similar names into a single zip folder

Posted on 2006-11-01
12
287 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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AS400 Logging Print device 2 77
PERL - Find newest folder 12 135
Windows 10 PRo Upgrade 21 76
good comptia a+ teacher? 4 102
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…
In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
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.

770 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