Re: Archive::Zip and correct extension (mixture of Word and PowerPoint files)?



Geoff Cox wrote:

Most of several thousand zip files, on a website, contained a single
Word doc. On moving the files to a CD I extracted all the zip files,
giving them a .doc extension and forgot that a few hundred where
either PowerPoint files or Excel files.

Eh, what?

A ZIP file contains a compressed file tree, including ibnformation of
the exact original filename.

If your users didn't mess up the extensions, then you can just find them
in the archive.

If they used a bad filename (for example, all the same name) but with
the proper extension, then you just have to rename the extracted file,
keeping the extension.

So, if file-22.zip contained fred.ppt, the new file had to be called
file-22.ppt etc.

Like I said.

First extract the ZIP file in the normal way, in a directory of its own.

After that, rename the extracted file, keeping the original extension.
You can move the file to its final dir in one go (as long as the target
dir is on the same drive as the extracted file).

(my $newbasename = $zipfile) =~ s/\.zip$//i;
foreach my $oldname (glob "$extracteddir/*") {
(my $newname = $oldname) =~ s/.*(?=\.)/$dir\/$newbasename/;
rename $oldname, $newname;
}

There's no need to mess with methods of Archive::Zip.

--
Bart.
.



Relevant Pages

  • Re: Email
    ... I export the e-mails to my hard disk where they are saved ... Then I extract the messages I want (all or any ... They are extracted either with the extension "eml" ... DBXtract used to be a free utility and can still be found with Google on ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: Compressed (zipped) Folder "Cannot create output file."
    ... You have to rename the file you mentioned ... with the extension .zip, and then you can extract it as a regular ... zeloc's Profile: http://forums.techarena.in/member.php?userid=27986 ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Sorting files by name(i)
    ... I needed to extract the number from the filename without any extension. ... Dim ActivePath As String ...
    (microsoft.public.excel.programming)
  • Re: Extracting drive, path, filebasename WITH string functions and NOT system function ???
    ... I was told to use built-in functions like: ... I must use some string manipulation functions like: ... To extract the file name, use the "mid" function in order to extract all ... To extract the file extension, use the "mid" function in order to extract ...
    (microsoft.public.scripting.vbscript)
  • Re: How to extract file extensions?
    ... With excel macros, I have extracted filenames with extension in column ... i need to extract the extensions in Column F. Now, ...
    (microsoft.public.excel.programming)