Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Adding multiple files with similar names into a single zip folder

Posted on 2006-11-01
12
Medium Priority
?
296 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Occasionally Windows/Microsoft Updates will fail to update. We have found a code that will delete all temporary files and re-register all dll's related to Windows/Microsoft Updates! This works 99% of the time to get the updates working again! The…
As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
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.

618 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