in reply to Grouping files with the same name...

I would create automatically a zip for each customer (customerxxx.zip)containing his own files, grouping the entire set of files.
So you'd iterate the customers. All the known customers? Or just the distinct customers you can discern from the filenames in the "big directory"?

One approach (update: implemented by ikegami below) would be as follows:

Use opendir/readdir/closedir to find all the filenames, building a hash where the keys are the the distinct customer numbers (use a regexp to retrieve it from the filename) and the values are references to lists of filenames for each customer number.

When you've built the hash, iterate the keys (customers) where for each key you build a zip file (using say Archive::Zip) adding the files listed against that key to the archive.

You might even remove the source files at the same time if that's your preference.

-David

  • Comment on Re: Grouping files with the same name...