Sunday, August 16, 2009

Backing up 'My Pictures'

I use Picasa to manage my pictures, all of them. The problem I have and a preference is that while I keep some of them on my laptop, which is backed up weekly, I'd like the bulk of them archived to my external drives.

The following is a batch file (.CMD) that will archive my files from my laptop to my "T:" drive, then back up that collection, complete to my "G:" drive. It also tries to process the Picasa Album databases, but I'm not sure this is working ideally yet. When running this batch file ensure Picasa is not running, and relax.
@echo off
CLS
SET backupDest1=T:\Archive of My Pictures
SET backupDest2=G:\Backup of My Pictures
TITLE Backup Up Picasa Album Settings...
FOR /F "tokens=1,2,3,4,5 delims=/ " %%a in ('date /T') do SET backupDate=%%c%%b%%a
PUSHD "%USERPROFILE%\Local Settings\Application Data\Google\Picasa2Albums\"
IF NOT EXIST "%backupDest1%" MKDIR "%backupDest1%"
IF NOT EXIST "%backupDest1%\_AlbumInfo" MKDIR "%backupDest1%\_AlbumInfo"
IF NOT EXIST "%backupDest1%\_AlbumInfo\%backupDate%" MKDIR "%backupDest1%\_AlbumInfo\%backupDate%"
robocopy backup "%backupDest1%\_AlbumInfo\backup" *.* /XO /S /E /ETA /V /R:3 /W:3
robocopy . "%backupDest1%\_AlbumInfo\%backupDate%" *.* /XO /XD backup /S /E /ETA /V /R:3 /W:3
TITLE Updating Album File Locations...
FOR /F "tokens=1,2,3,4,5 delims=:" %%a in ('echo %backupDest1%') do SET myPicsUpdate=[%%a]%%b
FOR /F %%a in ('dir /b /a:d-h "%backupDest1%\_AlbumInfo\%backupDate%\"') do call :cmpAInfo "%backupDest1%\_AlbumInfo\%backupDate%\%%a"
TITLE Clearing My Pictures...
robocopy "%USERPROFILE%\My Documents\My Pictures" "%backupDest1%" /S /E /ETA /MOVE /R:3 /W:3
TITLE Backing up %backupDest1% to %backupDest2%...
robocopy "%backupDest1%" "%backupDest2%" /XO /S /E /ETA /V /R:3 /W:3
TITLE Update Active Albums...
robocopy "%backupDest1%\_AlbumInfo\%backupDate%" . *.* /XO /XD backup /S /E /ETA /V /R:3 /W:3
if NOT EXIST "%USERPROFILE%\My Documents\My Pictures" MKDIR "%USERPROFILE%\My Documents\My Pictures"
popd
goto :eof
pause
TITLE Command Prompt
goto :eof

:cmpAInfo
echo Processing %~1...
REM FOR /F %%a in ('dir /b "%~1"') do echo "%~1\%%a"
FOR /F %%a in ('dir /b /a:-d "%~1"') do gsar -i -o -s"$My Pictures" -r"%myPicsUpdate%" "%~1\%%a"
goto :eof

Now... you'll need to verify your date format at the command prompt, mine is DD/MM/YYYY the line that sets the backupDate may need to be tweaked. Of course the two destination variables need to be set appropriately for your own needs. Have fun... but play it safe test this for yourself first.

gsar.exe - Global Search and Replace
robocopy - Microsoft's Robocopy


Sunday, July 26, 2009

Tired of loading that HP Photo and Imaging Director?

You can eliminate the use of this middle-man tool by creating Desktop or Quick Launch toolbar shortcuts to the actual program easily, but it takes some research. The first step is to figure out what application is being run when you click on the functions of this HP dashboard, this is done by watching your Task Manager and watching for a new image name to appear under processes. This is most likely the executable's filename so search for the imagename (i.e. hpqkygrp.exe) to find out where this file lives.

You'll need to rename imagename.exe to something else, I'd suggest _magename.exe (_pqkygrp.exe as an example) and copy this program to the folder you found that imagename in and rename it to the original application's name.

Click on that HP Photo & Imaging Director button again, this will open a dialog with the complete command line, copy this command line and create a shortcut in either your Quick Launch toolbar, or on the desktop.

Repeat this process for each of the buttons in this launcer application. It may work for other applications too, but this was my own challenge and I figured I'd share it with you.

Remember to rename the program back to what it was called originally, and keep WinEcho.exe for the next time you need it.

Wednesday, April 01, 2009

PHP error_reporting Code/Cypher

When developing code, a web site, in PHP it's handy to turn on some of the error_reporting functionality during debugging. To determin the correct code(s) to use try this simple Google Docs spreadsheet.

The principle is best explained in the PHP manual (available online and only a Google away), but this may help you understand what's being enabled and disabled and with the code required.

Examples (Lifted from the manual for your understanding):
// Turn off all error reporting
error_reporting(0);

// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);

// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);

// Report all PHP errors
error_reporting(E_ALL);

// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);

?>
PHP is one of the most powerful languages out there for web development, frankly there's not much it can't do when you add the right classes (which is like a DLL or Component on the ASP side) but the advantage is the cost... ZERO. If you want a development environment for your own personal machine, try out VirtualBox or VMWare Server and build one (Ubuntu or Ubuntu Server are great platforms, though OpenBSD, Debian, Fedora and the like are also popular and just as worthy). VMWare's VMTN has ready-to-use VMs you can simply plug in and fire up. I might pre-fab a couple of installations for VirtualBox over the next little while, no promises but if you're stuck let me know and I'll do what I can.

There is no individual ownership when you are part of a team, it's the sum of the parts that makes you the RESILIENT team you need to be.