Organizing Your Precious Internet Memories

Back when I first became a part of these internets, I’d get a lol or two via a link to a picture or a website. With the exception of a few of these pictures (thanks digg) most of these pictures have become distant memories of my past. After a while it occurred to me, why aren’t I saving these pictures?

However obsessive, I made it my job, nay, my duty to summon the strength to save and sort ever picture that strikes the slightest bit of interest. This, as you could imagine was a tedious task. Right click, navigate to proper folder, rename image (if needed) and save. My commitment was strong but apparently no match for this mundane method. Slowly, I would stop navigating to sub-folders and just drop them all in a folder I like to call “Internet Garbage”. Currently in the root of this folder, there resides over 3,000 unsorted images.

DON’T WAIT TO SORT YOUR FILES! This is the best advice I can give to anyone. Sure it’s easy to save everything to your desktop but chances are, you’ll mix it up, lose it, delete or whatever. If you put in the extra 20 seconds navigating/creating a relevant folder, you’ll save yourself a boatload of suffering.

Getting back on track though… I came across a Firefox extension a while back called Save Image in Folder. This extension saves you so much time and trouble, that you’d actually be wasting resources by saving files the old fashion way.

Go Install that extension and come back for a tutorial if you too, would like to start saving some ‘Internet Garbage’.

After Installing the extension, right click an image (it can be any image, we’re just using this to set things up quickly). You can use this image if you’d like:

omg_spoon_cat.jpg

Select “Save Image in Folder… >> Edit folders…”

step-1.png

Select “New”, click the folder button next to the “Path” textbox and create a new folder called “Internet Garbage”. Create all your sub folders inside of that folder.

For this example, I used:

- Art
- Funny
- Gross
- Macro
- Nerdy
- Sexy
- Wallpaper

You can add more whenever you please.

step-2.png

Note: You can prefix or suffice the filenames however you’d like. It’s not a bad idea to prefix the files with a short date… but it’s all up to you.

Once you have all your folders created, it’s a good idea to sort them alphabetically by using the up and down arrows located on the side of the Options dialog.

step-3.png

Now it’s as simple as right clicking an image and picking a folder it’s most relevant to save to.
step-4.png

Take Notes… The Easy Way

You know those times where you’re diddling around on the computer and want to take a quick note? We all have and unfortunately those notes we make to ourselves can sometimes get lost in the loads of “new text document (*).txt”’s found plentiful on our desktops.

After dealing with this lack of organization for some time, I “developed” (I use the term loosely) a quick windows solution to this that anyone can do with a few clicks. Check it out.

First: Open up explorer (windows key+e) and navigate to a directory of your choice.

step-one.png

Second: Create a folder called… say “My Toolbar”

step-two.png

Third: Create a text document named whatever you’d like (and optionally add shortcuts)

step-three.png

Fourth: Right click your task bar and select “Toolbars” then select “New Toolbar”

step-four.png

Fifth: Navigate to the folder you created

step-five.png

Sixth: Right click your new toolbar and uncheck “Show Text” and “Show Title”

step-six.png

Final Product:

step-seven.png

I hope this helps you clean up your note taking :)

To make it even EASIER, you can set the txt file to a hotkey using the program WinKey I mentioned in a previous post. I set mine to windows+s

Freeware I can’t believe I forgot to mention!

As I was running through some of my tasks yesterday, I realized I had forgotten to mention a few programs I tend to use quite often. So here they are in no particular order…

Unlocker

Ever try to delete a file on windows only to have it give you an error? You try and try to delete the file, closing all programs that may be associated with it? Well this bad boy right here will cure your frustration by allowing you to delete said files.

Desktop List View

Why this feature isn’t built into windows… I’ll never know. This little application will allow you to view the files on your desktop as you would if you had listed them in explorer, allowing you to take back some precious screen real estate.

DS Clock

Yeah, it’s ugly, so what, it tells time, it works flawlessly with dual monitors and I haven’t found a better alternative yet.

Notepad++

This is my text editor of choice. The tabbed files are what brought me to it, the regex find/replace is what kept me. The project is actively developed and I’ve seen it come a long way since version 3.1.

UXTheme Multi-Patcher

I’m not sure if this counts.. but it’s one of the first things I run after windows update on a fresh install. This patcher allows you to use your own windows themes. Many great ones can be found here but the best one is found here. RoyalFour is a slick modification of the default XP skin.

Check it out:

RoyalFour

My Computer Hardware

I split this off unto this post for quicker reference but don’t want to change history

I’ve been quite busy the past few days as I was switching from computer to computer. I just built a new computer to condense/protect my data a little better but I had to sell my old one to have enough funds for the new one. In the middle of the switch, I was on my laptop… which died because the AC input seems to be peeling off the motherboard and I have yet to have someone aide me in soldering it.

Here’s a little list of what I’ve slapped together for those interested:

- Lian-Li PC-61 Case
- OCZ GameXStream 600W Power Supply
- EVGA 122-CK-NF67-T1 Motherboard
- Intel Core 2 Duo E6600 Conroe 2.4GHz
- Crucial Ballistix 1GBx2 DDR2 PC2 6400 RAM
- XFX GeForce 7900GS Extreme
- WD 36gb Raptor HDD
- 4 Samsung Spintpoint T Series 500gb SATA 3Gb/s HDDs
- Samsung 18x DVD+-R DVD Burner with LightScribe
- Koutech Media Card Reader

After some debate I placed a second order for a separate RAID card and decided to go with the HighPoint RocketRAID 2300. So far, so good.

Anyhow, I love reformatting. There is something so refreshing about a clean install. I usually make myself a 10-15gb partition for windows so that I’ll be forced to put my personal files on another drive. This method worked for a while… but as applications increased in size, do did my partition. I decided to use all ~30 gigs of the Raptor for this install but I digress.

Freeware Programs I Can’t Live Without

I’ve been quite busy the past few days as I was switching from computer to computer. I just built a new computer to condense/protect my data a little better but I had to sell my old one to have enough funds for the new one. In the middle of the switch, I was on my laptop… which died because the AC input seems to be peeling off the motherboard and I have yet to have someone aide me in soldering it.

Here’s a little list of what I’ve slapped together for those interested:

- Lian-Li PC-61 Case
- OCZ GameXStream 600W Power Supply
- EVGA 122-CK-NF67-T1 Motherboard
- Intel Core 2 Duo E6600 Conroe 2.4GHz
- Crucial Ballistix 1GBx2 DDR2 PC2 6400 RAM
- XFX GeForce 7900GS Extreme
- WD 36gb Raptor HDD
- 4 Samsung Spintpoint T Series 500gb SATA 3Gb/s HDDs
- Samsung 18x DVD+-R DVD Burner with LightScribe
- Koutech Media Card Reader

After some debate I placed a second order for a separate RAID card and decided to go with the HighPoint RocketRAID 2300. So far, so good.

Anyhow, I love reformatting. There is something so refreshing about a clean install. I usually make myself a 10-15gb partition for windows so that I’ll be forced to put my personal files on another drive. This method worked for a while… but as applications increased in size, do did my partition. I decided to use all ~30 gigs of the Raptor for this install but I digress.

The real point of this post is about all the little applications I install upon a fresh format. Some programs go without mention because they are quite obvious, such as Firefox.

The List

allSnap

When I made the switch from Windows to Linux, there was one thing that I loved about gnome. The windows would snap to the edges of the monitor and other windows. When I made the switch back (hehe), I wanted to keep this feature with me and through my search, I came upon this little program which hasn’t failed me yet.

DM2

This little program has so many features, I don’t know where to begin. You can bind hotkeys or mouse clicks to perform special window operations, such as minimize to tray. There is also a right click dialog that’s added to every window which allows you to set the opacity, priority and always on top options.

Check out the website for details.

MW Snap

Awesome for taking quick screenshots. Very useful if you just want to save a picture of an application. Hotkeys too!

WinKey

I guess I just really like hotkeys. This little program allows you to bind any program to the windows key. I usually bind Firefox, Filezilla and PuTTy.

Irfan View

Picture/file browser with batch convert options. This is a really nice tool with plenty of available plugins to allow you to browse through not only pictures but text files, music, video, flash and more. I only really use it for pictures, it’s especially handy when you want to quickly view a large PSD but don’t feel like opening Photoshop.

I this thing doesn’t pack enough punch for you, check out XnView.

ColorPic

If you’re a web designer and you don’t have ColorPic, you need to get it now! It’s a very handy tool for creating and store palates or just figuring out what color a webpage/application is using.

K-Lite Codec Pack

The quick and dirty for all your codecs. A simple way to make sure all your files will play properly. DefilerPak is a lightweight alternative.

That about does it for my “must have” freeware :) .

Using PHP to sort Wallpapers by Dimension

Once upon a time, I found myself in possession of a vast amount of wallpapers. I’m talking well over 10,000, all in one folder. That’s not to helpful since a lot of them were repeats in different dimensions. After realizing that I couldn’t just add a ’sort by dimension’ field in explorer, I set about on a mission using a method I knew would work, PHP with the GD (Graphics Display) library.

The core of this script is based around the ability for GD to pull the dimensions of a picture quickly and efficiently. The goal is to get php to look in a directory and sort all their files by dimensions we define (this will help filter out any pictures in other dimensions present in the folder).

So the sorting cycle looks something like this:

$totalFiles=count($file);
for ($j=0; $j < $totalFiles; $j++)
{
    $dimension=getimagesize("$dir$file[$j]");
    for($k=0; $k < $totalFolders; $k++)
        if($dimension[0] == $width[$k] && $dimension[1] == $height[$k])
        {
            movefile($dir, $file[$j], "$dir$width[$k]x$height[$k]");
            $sorted++;
            if ($sorted%50==0) { echo $sorted." files sorted | ".round(100*($sorted/$totalFiles),2)."%\n";        }
    }
}

However, the folder is currently non-existent but we’re not going to open up explorer and create them ourself, especially since we plan on having an array hold our dimension values.

Here’s what I did:

$width = array(800,1024,1152,1280,1280,1280,1440,1600,1680,1920);
$height = array(600,768,864,800,960,1024,900,1200,1050,1200);
 
if (count($width) != count($height)) // Make sure the arrays are the same length
    exit ("Non-matching array lengths: ".count($width)." widths with ".count($height)." heights.");
 
$totalFolders=count($width);
for($i=0; $i < $totalFolders; $i++)  // Create directories based on the arrays if they haven't been created already
    if (!file_exists("$dir$width[$i]x$height[$i]"))
    {
        mkdir("$dir$width[$i]x$height[$i]");
        echo "Folder $width[$i]x$height[$i] created\n";
    }

The rest of the code is all pretty straight forward. I added in some job statistics (percentages and amount of time to complete). I have to find my pictures of the output but I believe it went through all the wallpapers in ~110 seconds. Anyway, here’s the script in it’s entirety, I hope it helps :) .

<?php
$dir = "pics/";                      // The directory (trailing slash)
$dh = opendir($dir);                 // Open the directory
$m_time = explode(" ",microtime());  // These two lines get the start time
$starttime = $m_time[0] + $m_time[1];//
$width = array(800,1024,1152,1280,1280,1280,1440,1600,1680,1920);
$height = array(600,768,864,800,960,1024,900,1200,1050,1200);
 
if (count($width) != count($height)) // Make sure the arrays are the same length
    exit ("Non-matching array lengths: ".count($width)." widths with ".count($height)." heights.");
 
$totalFolders=count($width);
for($i=0; $i < $totalFolders; $i++)  // Create directories based on the arrays if they haven't been created already
    if (!file_exists("$dir$width[$i]x$height[$i]"))
    {
        mkdir("$dir$width[$i]x$height[$i]");
        echo "Folder $width[$i]x$height[$i] created\n";
    }
// Create an array of the file names
while (false !== ($filename = readdir($dh))) {
   if (!is_dir($dir.$filename)) $file[] = $filename;
}
if (!isset($file))
    exit ("No files in this directory.");
 
$sorted=0;
$totalFiles=count($file);
for ($j=0; $j < $totalFiles; $j++)
{
    $dimension=getimagesize("$dir$file[$j]");
    for($k=0; $k < $totalFolders; $k++)
        if($dimension[0] == $width[$k] && $dimension[1] == $height[$k])
        {
            movefile($dir, $file[$j], "$dir$width[$k]x$height[$k]");
            $sorted++;
            if ($sorted%50==0) { echo $sorted." files sorted | ".round(100*($sorted/$totalFiles),2)."%\n";        }
    }
}
 
$m_time = explode(" ",microtime());  // These two lines get the end time
$endtime = $m_time[0] + $m_time[1];  //
echo "\n".$sorted." files have been sorted in ". round(($endtime - $starttime),3) ." seconds.\n";
echo "That's ".(1/(round(($endtime - $starttime),3)/$sorted))." files per second!";
 
function movefile($dir, $theFile, $newDir)
{
    if (!copy($dir.$theFile, "$newDir/$theFile")) echo "failed to copy $theFile...\n";
    else unlink($dir.$theFile);
}
?>

Note: This script should be called from the command line.

Using PHP to Make Excel Easier

Recently, I was presented with the task of counting the number times filenames repeated in an excel document. Being a 16,000+ row file, with well over 500 unique filenames, there was no simple solution in excel.

Having some experience exporting excel documents using PHP, I knew importing them wouldn’t be too hard. A few google searches later and I came across Excel Reader which fit the bill perfectly.

After sorting my excel document by filename, I created a loop in PHP that would read the first filename, count the number of times it repeated until it changed, then append that data to a string that would be exported to a new excel document once it was done reading the data.

// Starting at 2 to skip the headers | +1 so it compares the last row
for ($i = 2; $i <= $data->sheets[0]['numRows']+1; $i++) {
	if ($data->sheets[0]['cells'][$i][3]==$curFileName) {
		$curFileCount++;
	} else {
		// Output the data line:
"Device","User","Filename","Filecount"
		$stringData =
"\"".$data->sheets[0]['cells'][$i-1][1]."\",\"".$data->sheets[0]['cells'][$i
-1][2]."\",\"".$data->sheets[0]['cells'][$i-1][3]."\",\"".$curFileCount."\"\
n";
		fwrite($fh, $stringData);
 
		// Reset the count and update the curFileName
		$curFileName = $data->sheets[0]['cells'][$i][3];
		$curFileCount=1;
	}
	echo "Row: ".$i."\n";
}

Of course… I didn’t have just one of these files but 6 and manually entering each filename would be a waste of my time. My software solution for this was to create an “Input” and “Output” folder and have PHP cycle through the “Input” folder.

// For every file in the dir "Input", generate a report
if ($handle = opendir('Input')) {
	while (false !== ($orgFileName = readdir($handle))) {
		if($orgFileName != '..' && $orgFileName != '.') {
 
			// Echo the file we're reading, then read that file
			echo $orgFileName."\n";
			$data->read("Input/".$orgFileName);

Eventually it all came together as such:

<?php
 
// Don't change any of this
require_once 'Excel/reader.php';
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('CP1251');
 
// For every file in the dir "Input", generate a report
if ($handle = opendir('Input')) {
	while (false !== ($orgFileName = readdir($handle))) {
		if($orgFileName != '..' && $orgFileName != '.') {
 
			// Echo the file we're reading
			echo $orgFileName."\n";
			$data->read("Input/".$orgFileName);
 
			// Set the first filename to compare
			$curFileName =
$data->sheets[0]['cells'][2][3]==$curFileName;
			$curFileCount = 0;
 
			// Create a file and open it for writing
			$myFile =
"Output/File_Count-".str_replace(".xls",".csv",$orgFileName);
			$fh = fopen($myFile, 'w') or die("can't open file");
 
			// Starting at 2 to skip the headers | +1 so it
compares the last row
			for ($i = 2; $i <= $data->sheets[0]['numRows']+1;
$i++) {
				if
($data->sheets[0]['cells'][$i][3]==$curFileName) {
					$curFileCount++;
				} else {
					// Output the data line:
"Device","User","Filename","Filecount"
					$stringData =
"\"".$data->sheets[0]['cells'][$i-1][1]."\",\"".$data->sheets[0]['cells'][$i
-1][2]."\",\"".$data->sheets[0]['cells'][$i-1][3]."\",\"".$curFileCount."\"\
n";
					fwrite($fh, $stringData);
 
					// Reset the count and update the
curFileName
					$curFileName =
$data->sheets[0]['cells'][$i][3];
					$curFileCount=1;
				}
				echo "Row: ".$i."\n";
			}
			// Close file
			fclose($fh);
		}
	}
}
?>

My apologies for the less than perfect code, I was on a deadline and perfect code wasn’t a requirement :) .

Here are some screenshots of the script in action.

PHP Excel File Count - Screenshot 1

PHP Excel File Count - Screenshot 2

PHP Excel File Count - Screenshot 3