Multi Commander > Script
Create date folders for a whole year
(1/1)
Mathias (Author):
Somebody ask me for how to create date folders for a whole year using script.
Well here is how you do it.
This script will create 365 date folders.
D:\Test\2013-01-01
D:\Test\2013-01-02
D:\Test\2013-01-03
and so on
--- Code: ---// set time to "2013-01-01 00:00:00" - the value is seconds from 1970-01-01 00:00:00 - use http://www.epochconverter.com/ to get the start value
@var $time = 1356998400;
// Path to where you want to create the folders
@var $FolderBaseName = "D:\\Test\\";
@var $date = "";
@var $folder;
@var $n = 0;
for( $n = 0; $n < 365; $n++ )
{
$date = FormatDate( "yyyy-MM-dd" , $time );
$folder = $FolderBaseName ^ $date;
MC.Filesystem.Makedir PATH="{$folder}"
// Increase value by the seconds of a day
$time = $time + 86400;
}
--- End code ---
sl23:
I'm interested in using this, but just for months not days, I imagine it can be adapted for that purpose?
If so, I'd like to look into how to adapt it myself as a starting point in learning a little about scripts. Do you know of any good resources?
Thanks
Mathias (Author):
Since there are only 12 months. it is faster to just write the script with hardcoded date..
--- Code: ---@var $FolderBaseName = "D:\\Test\\";
$folder = $FolderBaseName ^ "2015-01";
MC.Filesystem.Makedir PATH="{$folder}"
$folder = $FolderBaseName ^ "2015-02";
MC.Filesystem.Makedir PATH="{$folder}"
$folder = $FolderBaseName ^ "2015-03";
MC.Filesystem.Makedir PATH="{$folder}"
$folder = $FolderBaseName ^ "2015-04";
MC.Filesystem.Makedir PATH="{$folder}"
$folder = $FolderBaseName ^ "2015-05";
MC.Filesystem.Makedir PATH="{$folder}"
$folder = $FolderBaseName ^ "2015-06";
MC.Filesystem.Makedir PATH="{$folder}"
$folder = $FolderBaseName ^ "2015-07";
MC.Filesystem.Makedir PATH="{$folder}"
$folder = $FolderBaseName ^ "2015-08";
MC.Filesystem.Makedir PATH="{$folder}"
$folder = $FolderBaseName ^ "2015-09";
MC.Filesystem.Makedir PATH="{$folder}"
$folder = $FolderBaseName ^ "2015-10";
MC.Filesystem.Makedir PATH="{$folder}"
$folder = $FolderBaseName ^ "2015-11";
MC.Filesystem.Makedir PATH="{$folder}"
$folder = $FolderBaseName ^ "2015-12";
MC.Filesystem.Makedir PATH="{$folder}"
--- End code ---
Navigation
[0] Message Index
Go to full version