# Rubyzip problem / question

**URL:** <https://www.ruby-forum.com/t/rubyzip-problem-question/72511>\
**Category:** Ruby\
**Created:** [October 17, 2006, 6:51pm UTC](https://www.ruby-forum.com/t/rubyzip-problem-question/72511 "2006-10-17T18:51:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eada6e/32.png) [@dan](https://www.ruby-forum.com/u/dan)\
**Post date:** [October 17, 2006, 6:51pm UTC](https://www.ruby-forum.com/t/rubyzip-problem-question/72511/1 "2006-10-17T18:51:42Z")

</div>

Hi,

I’m fairly new to ruby and am trying to use the rubyzip library (I  
downloaded the latest gem) to change a directory name in a zipped file.  
The code below seems to work (i.e. the directory names show as changed  
in winzip), but I get “crc errors” when I try to actually decompress  
the file. I’d really like to avoid the overhead of unzipping and  
re-zipping each file. Any suggestions would be greatly appreciated!

require ‘zip/zip’

target = “test.zip”

Zip::ZipFile.open(target) do |zipfile|  
zipfile.each do |e|  
if !e.directory? and e.to\_s.include? “olddir”  
zipfile.rename(e.to\_s, e.to\_s.gsub(“olddir”, “newdir”))  
end  
end  
end

- Dan

---

<div class="post-metadata">

**Author:** ![dan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/eada6e/32.png) [@dan](https://www.ruby-forum.com/u/dan)\
**Post date:** [December 14, 2006, 9:37am UTC](https://www.ruby-forum.com/t/rubyzip-problem-question/72511/2 "2006-12-14T09:37:11Z")

</div>

> Hi,

Hello

> target = “test.zip”
> 
> Zip::ZipFile.open(target) do |zipfile|  
> zipfile.each do |e|  
> if !e.directory? and e.to\_s.include? “olddir”  
> zipfile.rename(e.to\_s, e.to\_s.gsub(“olddir”, “newdir”))  
> end  
> end  
> end

I’ve got exactly the same problem. I sent the information to the  
developers of rubyzip and they created a bug in the tracker.

Just in case, has someone found a solution of that ? Maybe an unknown  
patch ? 🙂  
Thanks in advance,  
Regards,  
++ Jerome
