Blatantly abusing the Windows search function: a very lazy note-taking idea

Often, as I am minding my daily business, I would suddenly have an interesting thought, or some idea. Being likely to forget it a few minutes later, I would want to write the idea down. But being a lazy and slightly disorganized person, I would grab the nearest pencil and scrap paper, scribble down a few words, and throw the piece of paper aside somewhere.

Usually I would never retrieve that piece of paper again. But occasionally I do want to read the note I wrote. After a few minutes of searching I would usually find the piece of paper I needed. If I didn’t, oh well, it probably wasn’t that important anyway.

But, as you can imagine, this quickly gets out of hand.

Now you would like to do do the note taking on the computer, instead on small pieces of paper. After all, losing files is harder on the computer right?

But how would you do this? In the computer world it’s a bit harder to ‘throw aside’ a file. You have to give the file a name, and put it in some directory, essentially forcing you to be organized. Or if you don’t, files clutter up your computer desktop even faster than sheets of paper clutter up your actual desk.

So being the geek I am, I wrote up my experimental, software solution. Then writing a note would go as follows. You open up command prompt, and enter the note command:

Type up whatever you want, and then hit save:

So your note is saved in some obscure directory of your choosing. Now the Windows 7 search is pretty good (Windows Vista works too) that as long as your directory is indexed, Windows-F and typing pretty much anything in the search bar would quickly bring you to the file (it searches file contents):

Searching for “phone ashley” takes me directly to the note.┬áThe program just takes what we’ve written, and saves it in a unique file that also has a datestamp on it. For example the first note written on a day would have _1 appended to it, then _2, and so on.

I’m not yet sure how practical this idea would be, but here’s the C++ code for my program:


#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <ctime>
using namespace std;

// Folder that we are going to write notes in
string NPATH = "C:/home/notes/";

// Convert integer to string
string istr(int i)
{
  stringstream ss;
  ss << i;
  return ss.str();
}

// Convert time to displayable form with year, month, day, for example
// 2010-01-01. Always 10 characters long.
string formTime(struct tm * cur)
{
  char s[11];
  sprintf(s, "%04d-%02d-%02d",
    cur->tm_year + 1900, // Number of years since 1900
    cur->tm_mon + 1,     // Month, starting at 0
    cur->tm_mday);       // Day of month
  return s;
}

// Does the file at this path exist, or not?
bool existsFile(string path)
{
  ifstream ifs(path.c_str());
  return ifs;
}

void write(string data)
{
  // Get current time
  time_t curr_t = time(NULL);
  tm * curr = localtime(&curr_t);

  // 1 might be already occupied, or 2, so fill first unoccupied one
  int ext = 1;
  string filebase = NPATH + formTime(curr);
  string flocation;
  
  do{
    flocation = filebase + "_" + istr(ext) + ".txt";
    ext++;
  }while(existsFile(flocation));

  // Write everything to the file
  ofstream fout;
  fout.open(flocation.c_str());
  fout << data;
  fout.close();
}

int main()
{
  stringstream ss;

  // Accept input until line is "save" or "exit"
  string s;
  while(true){
    getline(cin,s);
    if(s == "save") break;
    if(s == "exit") return 0;
    ss << s << '\n';
  };

  // Write everything and exit
  write(ss.str());
  return 0;
}

3 Responses to Blatantly abusing the Windows search function: a very lazy note-taking idea

  1. trax 0101 says:

    coolness *thumbs up*

  2. Amit Patel says:

    Nifty! I’m doing it the other way around: I have a hotkey that opens an editor window and puts the cursor at the very bottom. I type into there and close the window. Then I use Find inside that file to go through my notes. I had found myself wanting to move things around between notes, or extend an existing one, instead of always making a new one, so this approach worked out better than having a separate file for each note.

  3. Anonymous says:

    Neat idea, though I do this already without a program to help me. It’s kind of sad.

    I know someone who also puts randomly generated passwords for various sites in random TXT’s all over his computer, so even if people got them they’d be useless. The only problem is that he forgets where all the passwords are.

    It would be neat if you could actually apply an artificial intelligence to it. Windows Search isn’t exactly ideal. You could always write your own little search-software that would go through either a directory or a single file that notes are appended to.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 61 other followers

%d bloggers like this: