Open in TheBrain

Date Scripts

<p>Taken from the <a href="http://forums.thebrain.com/post?id=4266677" rel="nofollow">Creating Thoughts Each Week Hassle Free</a> forum post.

Credit provided to CD for the dates and perl script.</p>

<blockquote>

<p>Hi all,

didn't know where to post, looked best here, so...

since i needed this and didn't want to type everything by hand, here's a handy copy-paste i.o. to create thoughts relating to every week of the year 2010:

Code:

<code>KW 01 (4/1/2010-10/1/2010);KW 02 (11/1/2010-17/1/2010);KW 03 (18/1/2010-24/1/2010);KW 04 (25/1/2010-31/1/2010);KW 05 (1/2/2010-7/2/2010);KW 06 (8/2/2010-14/2/2010);KW 07 (15/2/2010-21/2/2010);KW 08 (22/2/2010-28/2/2010);KW 09 (1/3/2010-7/3/2010);KW 10 (8/3/2010-14/3/2010);KW 11 (15/3/2010-21/3/2010);KW 12 (22/3/2010-28/3/2010);KW 13 (29/3/2010-4/4/2010);KW 14 (5/4/2010-11/4/2010);KW 15 (12/4/2010-18/4/2010);KW 16 (19/4/2010-25/4/2010);KW 17 (26/4/2010-2/5/2010);KW 18 (3/5/2010-9/5/2010);KW 19 (10/5/2010-16/5/2010);KW 20 (17/5/2010-23/5/2010);KW 21 (24/5/2010-30/5/2010);KW 22 (31/5/2010-6/6/2010);KW 23 (7/6/2010-13/6/2010);KW 24 (14/6/2010-20/6/2010);KW 25 (21/6/2010-27/6/2010);KW 26 (28/6/2010-4/7/2010);KW 27 (5/7/2010-11/7/2010);KW 28 (12/7/2010-18/7/2010);KW 29 (19/7/2010-25/7/2010);KW 30 (26/7/2010-1/8/2010);KW 31 (2/8/2010-8/8/2010);KW 32 (9/8/2010-15/8/2010);KW 33 (16/8/2010-22/8/2010);KW 34 (23/8/2010-29/8/2010);KW 35 (30/8/2010-5/9/2010);KW 36 (6/9/2010-12/9/2010);KW 37 (13/9/2010-19/9/2010);KW 38 (20/9/2010-26/9/2010);KW 39 (27/9/2010-3/10/2010);KW 40 (4/10/2010-10/10/2010);KW 41 (11/10/2010-17/10/2010);KW 42 (18/10/2010-24/10/2010);KW 43 (25/10/2010-31/10/2010);KW 44 (1/11/2010-7/11/2010);KW 45 (8/11/2010-14/11/2010);KW 46 (15/11/2010-21/11/2010);KW 47 (22/11/2010-28/11/2010);KW 48 (29/11/2010-5/12/2010);KW 49 (6/12/2010-12/12/2010);KW 50 (13/12/2010-19/12/2010);KW 51 (20/12/2010-26/12/2010);KW 52 (27/12/2010-2/1/2011);</code>

If you prefer M-D-Y ordering:

<code>KW 01 (1/4/2010-1/10/2010);KW 02 (1/11/2010-1/17/2010);KW 03 (1/18/2010-1/24/2010);KW 04 (1/25/2010-1/31/2010);KW 05 (2/1/2010-2/7/2010);KW 06 (2/8/2010-2/14/2010);KW 07 (2/15/2010-2/21/2010);KW 08 (2/22/2010-2/28/2010);KW 09 (3/1/2010-3/7/2010);KW 10 (3/8/2010-3/14/2010);KW 11 (3/15/2010-3/21/2010);KW 12 (3/22/2010-3/28/2010);KW 13 (3/29/2010-4/4/2010);KW 14 (4/5/2010-4/11/2010);KW 15 (4/12/2010-4/18/2010);KW 16 (4/19/2010-4/25/2010);KW 17 (4/26/2010-5/2/2010);KW 18 (5/3/2010-5/9/2010);KW 19 (5/10/2010-5/16/2010);KW 20 (5/17/2010-5/23/2010);KW 21 (5/24/2010-5/30/2010);KW 22 (5/31/2010-6/6/2010);KW 23 (6/7/2010-6/13/2010);KW 24 (6/14/2010-6/20/2010);KW 25 (6/21/2010-6/27/2010);KW 26 (6/28/2010-7/4/2010);KW 27 (7/5/2010-7/11/2010);KW 28 (7/12/2010-7/18/2010);KW 29 (7/19/2010-7/25/2010);KW 30 (7/26/2010-8/1/2010);KW 31 (8/2/2010-8/8/2010);KW 32 (8/9/2010-8/15/2010);KW 33 (8/16/2010-8/22/2010);KW 34 (8/23/2010-8/29/2010);KW 35 (8/30/2010-9/5/2010);KW 36 (9/6/2010-9/12/2010);KW 37 (9/13/2010-9/19/2010);KW 38 (9/20/2010-9/26/2010);KW 39 (9/27/2010-10/3/2010);KW 40 (10/4/2010-10/10/2010);KW 41 (10/11/2010-10/17/2010);KW 42 (10/18/2010-10/24/2010);KW 43 (10/25/2010-10/31/2010);KW 44 (11/1/2010-11/7/2010);KW 45 (11/8/2010-11/14/2010);KW 46 (11/15/2010-11/21/2010);KW 47 (11/22/2010-11/28/2010);KW 48 (11/29/2010-12/5/2010);KW 49 (12/6/2010-12/12/2010);KW 50 (12/13/2010-12/19/2010);KW 51 (12/20/2010-12/26/2010);KW 52 (12/27/2010-1/2/2011);</code>

Just create a thought "Weeks 2010" or what have you and create a child, paste everything in and off you go. Also: To get rid/replace the "KW" part (German for Kalenderwoche) i suggest find&replace in your preferred editor.

Maybe this is useful to anyone. Btw: I made this with perl, if you want the source, pm me.

Cheers

Chris

To save someone some regex work, here's the same thing formatted as:

WW (YYYY-MM-DD to YYYY-MM-DD)

Code:

<code>01 (2010-01-04 to 2010-01-10); 02 (2010-01-11 to 2010-01-17); 03 (2010-01-18 to 2010-01-24); 04 (2010-01-25 to 2010-01-31); 05 (2010-02-01 to 2010-02-07); 06 (2010-02-08 to 2010-02-14); 07 (2010-02-15 to 2010-02-21); 08 (2010-02-22 to 2010-02-28); 09 (2010-03-01 to 2010-03-07); 10 (2010-03-08 to 2010-03-14); 11 (2010-03-15 to 2010-03-21); 12 (2010-03-22 to 2010-03-28); 13 (2010-03-29 to 2010-04-04); 14 (2010-04-05 to 2010-04-11); 15 (2010-04-12 to 2010-04-18); 16 (2010-04-19 to 2010-04-25); 17 (2010-04-26 to 2010-05-02); 18 (2010-05-03 to 2010-05-09); 19 (2010-05-10 to 2010-05-16); 20 (2010-05-17 to 2010-05-23); 21 (2010-05-24 to 2010-05-30); 22 (2010-05-31 to 2010-06-06); 23 (2010-06-07 to 2010-06-13); 24 (2010-06-14 to 2010-06-20); 25 (2010-06-21 to 2010-06-27); 26 (2010-06-28 to 2010-07-04); 27 (2010-07-05 to 2010-07-11); 28 (2010-07-12 to 2010-07-18); 29 (2010-07-19 to 2010-07-25); 30 (2010-07-26 to 2010-08-01); 31 (2010-08-02 to 2010-08-08); 32 (2010-08-09 to 2010-08-15); 33 (2010-08-16 to 2010-08-22); 34 (2010-08-23 to 2010-08-29); 35 (2010-08-30 to 2010-09-05); 36 (2010-09-06 to 2010-09-12); 37 (2010-09-13 to 2010-09-19); 38 (2010-09-20 to 2010-09-26); 39 (2010-09-27 to 2010-10-03); 40 (2010-10-04 to 2010-10-10); 41 (2010-10-11 to 2010-10-17); 42 (2010-10-18 to 2010-10-24); 43 (2010-10-25 to 2010-10-31); 44 (2010-11-01 to 2010-11-07); 45 (2010-11-08 to 2010-11-14); 46 (2010-11-15 to 2010-11-21); 47 (2010-11-22 to 2010-11-28); 48 (2010-11-29 to 2010-12-05); 49 (2010-12-06 to 2010-12-12); 50 (2010-12-13 to 2010-12-19); 51 (2010-12-20 to 2010-12-26); 52 (2010-12-27 to 2011-01-02)</code>

and YYYY-MM-DD to YYYY-MM-DD

<code>2010-01-04 to 2010-01-10; 2010-01-11 to 2010-01-17; 2010-01-18 to 2010-01-24; 2010-01-25 to 2010-01-31; 2010-02-01 to 2010-02-07; 2010-02-08 to 2010-02-14; 2010-02-15 to 2010-02-21; 2010-02-22 to 2010-02-28; 2010-03-01 to 2010-03-07; 2010-03-08 to 2010-03-14; 2010-03-15 to 2010-03-21; 2010-03-22 to 2010-03-28; 2010-03-29 to 2010-04-04; 2010-04-05 to 2010-04-11; 2010-04-12 to 2010-04-18; 2010-04-19 to 2010-04-25; 2010-04-26 to 2010-05-02; 2010-05-03 to 2010-05-09; 2010-05-10 to 2010-05-16; 2010-05-17 to 2010-05-23; 2010-05-24 to 2010-05-30; 2010-05-31 to 2010-06-06; 2010-06-07 to 2010-06-13; 2010-06-14 to 2010-06-20; 2010-06-21 to 2010-06-27; 2010-06-28 to 2010-07-04; 2010-07-05 to 2010-07-11; 2010-07-12 to 2010-07-18; 2010-07-19 to 2010-07-25; 2010-07-26 to 2010-08-01; 2010-08-02 to 2010-08-08; 2010-08-09 to 2010-08-15; 2010-08-16 to 2010-08-22; 2010-08-23 to 2010-08-29; 2010-08-30 to 2010-09-05; 2010-09-06 to 2010-09-12; 2010-09-13 to 2010-09-19; 2010-09-20 to 2010-09-26; 2010-09-27 to 2010-10-03; 2010-10-04 to 2010-10-10; 2010-10-11 to 2010-10-17; 2010-10-18 to 2010-10-24; 2010-10-25 to 2010-10-31; 2010-11-01 to 2010-11-07; 2010-11-08 to 2010-11-14; 2010-11-15 to 2010-11-21; 2010-11-22 to 2010-11-28; 2010-11-29 to 2010-12-05; 2010-12-06 to 2010-12-12; 2010-12-13 to 2010-12-19; 2010-12-20 to 2010-12-26; 2010-12-27 to 2011-01-02</code>

here's the Perl Script that will allow you to use any naming conventions you like and use it next year ;-)

>Quote:

<code>#!/usr/bin/perl

use Date::Calc qw(Weeks_in_Year Week_of_Year Monday_of_Week Add_Delta_Days);

$y = 2010; &nbsp;# what year are we working on&nbsp;

$format = 2; # change to 2 if you want a M-D-Y ordering

for ($i =1; $i <= Weeks_in_Year($y); $i++) {

($year,$month,$day) = Monday_of_Week($i,$y);

get the date one week later

($nyear,$nmonth,$nday) = Add_Delta_Days(Monday_of_Week(Week_of_Year($year,$ month,$day)),6);

&nbsp; # print&nbsp;

&nbsp; print "KW "; &nbsp; &nbsp;# or what have you "WW"...

($i <= 9) ? print "0" : 1;

&nbsp; if ($format == 1) {

&nbsp; print "$i ($day/$month/$year-$nday/$nmonth/$nyear);";&nbsp;

&nbsp; } else {&nbsp;

print "$i ($month/$day/$year-$nmonth/$nday/$nyear);";

&nbsp; }

}

exit;</code></p>

<p>

The 3rd posts output would require a&nbsp;

Quote:

<code>print "$i ($year-$month-$day to $nyear-$nmonth-$nday);";</code>

as well as the replaced "KW" to "WW".

Should be easy to adjust to anyone's needs.</p>

</blockquote>