Revision: 5311
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 27, 2008 12:10 by karelklic
Initial Code
import java.util.zip.* import java.text.* def toBase2(String sText){ boolean bChar = true int iSize = sText.length() int i = 0 String sAux = "" for (i=0; i < iSize; i++) { String sLetter = sText.charAt(i) sLetter = Normalizer.normalize(sLetter, Normalizer.Form.NFD) try{ byte[] bLetter = (new String(sLetter)).getBytes("UTF-8") char cLetter = (char) bLetter[0] sAux += "" + cLetter } catch(Exception e){ } } return sAux } new File(args[0]).eachFileRecurse() { f -> if (f ==~ /.*zip$/ || !f.isFile()) return name = f.toString() zipname = name.substring(0, name.lastIndexOf(".")) + ".zip" out = new ZipOutputStream(new FileOutputStream(zipname)) nameInZip = toBase2(name.substring(name.lastIndexOf("\\") + 1)) println nameInZip out.putNextEntry(new ZipEntry(nameInZip)) // nejde napsat out.write(f.readbytes()), protoze na 100mb // souboru to zahlasi out of memory ins = f.newInputStream() buffer = new byte[18024] while ((len = ins.read(buffer)) > 0) out.write(buffer, 0, len) out.closeEntry() out.close() }
Initial URL
Initial Description
Removes diacritics from file name before adding it to the archive. Archive file name retains diacritics.
Initial Title
Compresses all the files in some directory recursively (zip); solves diacritics problems
Initial Tags
file
Initial Language
Groovy