Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Sorry this question is trivial, but I couldn't get it to work: I have a folder full of .zip files, each .zip file contains exactly one .xml file. The zip files have sensible names like etc., while the .xml file contained in them have some "randomname".xml

Now I want to unpack all the .zip files in the folder, preserving the name of the .zip files, so that gets unpacked into a.xml, into b.xml etc...

I only managed to achieve a batch unpacking with the command:

for z in *.zip; do unzip "$z"; done How do I enhance this to keep the names?

share|improve this question

Assuming you don't have any .xml files in that directory when you start and each .zip only has exactly one .xml file, you could do this.

for z in *.zip; do
   unzip $z
   mv *.xml `echo $z | sed "s/\.zip$/.xml/"`
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .