title: A good way to merge files according to the file name python or bash
body: <p>I have thousands of zipped csv files named like this:</p>
  
  <pre><code>result-20120705-181535.csv.gz
  </code></pre>
  
  <p>181535 means 18:15:35, now I want to merge these files on daily basis(I have data over a week, all named like the above example), from 2:00 am in the morning till 2:00 am the next day,then moved the processed files into a folder called merged</p>
  
  <p>so in the current folder, I have tons of .csv.gz files, and I want to scan the names, merge everything like <code>20120705-02*, 20120705-03*</code>...until <code>20120706-01*</code> into <code>20120705-result.csv.gz</code>, then move <code>20120705-02*, 20120705-03*</code>...until <code>20120706-01*</code> files into a folder called merged, and started to find the next day's data: <code>20120706-02*.....20120707-01*</code></p>
  
  <p>I am wondering whether to use python or bash script to do it, and how?</p>