Create the shortest script that organizes all the logs by month and date.
Rules
Syntax
organize <folder to scan> <folder to place logs>
- folder cannot be root
- the two folder should be different and not contain one another
Behaviour
The script should scan all the *.log files in <folder to scan>
and copy them to <folder to place logs>
in sub-folders corresponding to the year and month of the last modified time of the log file, named like year_month
.
Example:
organize /var/log/apache2 /temp/logs
would give folder structure like this:
/temp/logs/
|-- 2014_01
|-- 2014_02
|-- 2014_03
|-- 2014_04
|-- 2014_05
Languages, environment
All languages and OSs are permitted but need to be specified.
But since this is a code-golf question, script languages (python, bash, windows batch) will be more fit from the start.