Forums

Discuss all things Remember The Milk.

Adding a static set of tasks on demand

jgoethals says:
I just started RTM a few days ago (signed up for Pro today) and one of my first tasks was trying to automate the first annoyance I hit. I have a task list called 'h-Laundry' for doing laundry tasks. I wash four different types of laundry; delicates, darks, whites, diapers. Each type requires slightly different steps and different settings on the machines.

As a long time software developer, and now stay-at-home dad, I am always looking for ways to automate repetitive steps as a single, easy action. I thought about making each set of tasks a weekly recurrence, but that's not exactly how I work. When I add things to each dirty clothes basket, I usually assess at that time whether I should do that laundry.

So I wanted a way to add my 2-6 steps to my h-Laundry list on-demand. My solution was to write a quick Win7 PowerShell script that would take a .txt file containing the list name and the necessary pre-written steps and email them to my RTM import email, thus adding them directly.

For anyone else using Win7 at home and interested in the technique, here is how I set it up. These instructions do require some computer knowledge in creating files. If you have specific problems and want to use it, I can try to help out where I can.

1) You need to allow your computer to run Powershell scripts. This is only required once on your computer. I had to do this:

START->All programs->Accessories->Windows PowerShell-> (right-click 'Windows PowerShell' at the bottom) -> Run As Administrator

At the PS prompt:
> Set-ExecutionPolicy RemoteSigned

Then choose the default of "Y" to allow scripts you write to run. Type exit to close the window. Now to write the scripts.

2) Create a folder to store the scripts and your text files containing tasks. I created one called "PowerScripts" on my desktop.

Right-click on the desktop
Select New->Folder
Type the name as "PowerScripts"

3) Create the PowerShell script in the PowerScripts directory. This uses a Gmail account to send and will require you have a GMail account and store your password in this file. I have purposefully hidden my real data in the example below, so you will need to replace the obvious fake data with your own.

Fake data:
my_gmail@gmail.com <-- enter your GMail address
my_rtm_username+9999aa+import@rmilk.com <-- enter your RTM import address
my_password <--- enter your GMail password

Note: You may want to set $EmailTo to you own GMail account at first in order to test that the script is working before you start sending weird data to RTM.

filename: zRTM-send.ps1
--- copy below this line ---
$EmailFrom = “my_gmail@gmail.com”
$EmailTo = “my_rtm_username+9999aa+import@rmilk.com”
$Subject = Get-Content -Path $args | Select-Object -index 0
$Message = Get-Content -Path $args | Select-Object -Skip 1
$Body = $Message -join "`r`n"
$SMTPServer = “smtp.gmail.com”
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true
$SMTPClient.Credentials = New-Object System.Net.NetworkCredential(“my_gmail@gmail.com”, “my_password”);
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
--- copy above this line ---

4) Create a Windows CMD batch file to allow easy drag/drop of your text file. Again, create it in the PowerScripts folder.

filename: _Drop-On-Me.cmd
--- copy below this line ---
powershell "& 'C:\Users\your-name\Desktop\PowerScripts\zRTM-send.ps1' '%1'
--- copy above this line ---

Note that it needs the path to PowerShell file you created in step 3. You should replace "your-name" with your Win7 user name.

5) Create .txt files for your list of tasks. Here is an example of one of mine.

filename: Laundry-Diapers.txt
--- copy below this line ---
h-Laundry
4.1 soak diapers
4.2 agitate with whitening powder and let sit overnight
4.3 finish wash cycle ^tomorrow
4.4 hang diapers ^tomorrow
4.5 fluff diapers ^tomorrow
4.6 fold diapers ^tomorrow
--- copy above this line ---

I use the numbering system so that the tasks all sort in the order I need to do them.

6) Now everyone is setup. Whenever you want those 6 tasks to be added to RTM, just drag the "Laundry-Diapers.txt" file and drop it onto the "_Drop-On-Me.cmd" file and it will do the rest.

Cheers.



Posted at 4:29am on February 18, 2013
Log in to post a reply.