Monthly Archives: December 2011

Backing up Newsgator files with Powershell

I use Newsgator to get my RSS feeds. It still works even with the latest version of Outlook. I have been looking for another RSS reader that works within Outlook but always come back to Newsgator.

I regularly backup the files but do it manually as I have to unhide the hidden files on the C drive. Navigate to the directory where the files are located and copy them to another location. And then remember to hide the hidden files again on the C drive.

In the end, I decided to write a script that copies the files from the Newsgator directory to another location that is specified.

The Powershell script can be ran each day or once a week. To use the script, you need to have Newsgator installed along with Powershell.

If you are running Windows 7 and Windows Server 2008 R2, you have Powershell already installed.

if you are running Windows Vista, XP. You need to download Powershell. You can download PowerShell here.

Before you run it, a couple of things should be changed in the script.

The destDir variable creates a folder on the D drive. You can leave or change the folder name but the drive should be changed. The D drive is where I have all my files and data stored. I put a date at the end of the folder as I like to have the date it was copied over.

In the src variable, replace xxxx with your user name on the C drive. The user name is your login name as well. For example, if the user name is Acme it would be C:\Users\Acme\….

# Setup the local variables
# Set the source directory and get all the files in the directory
$src = "C:\Users\xxxx\AppData\Roaming\RAI\NewsGator\*"
# Get the date and change the / to - as Windows will get confused when
# creating new directories.
$currDate = Get-Date
$NewDate = $currDate.ToShortDateString()
$NewDate = $NewDate.Replace("/", "-")
# Set the destination directory with the new Date
$destDir = "D:\NewsGator Backup - " + $NewDate
# Test if the path exists
if (Test-Path $destDir)
    Write-Host "Directory exists"
    #Write-Host "**does not exist"
    # Create destination directory
    New-Item $destDir -type directory -force 
    Write-Host "Directory created"    
# Copy the files to the directory
Copy-Item $src $destDir
Write-Host "Files copied over"

Copy the script above. Open Notepad and paste the code in. Save it to a location on your hard drive and name it NGFiles.ps1

Create a new document in Notepad and paste the following line in.

powershell -executionpolicy bypass -File NGFiles.ps1

Save it as NGBat.bat. This file must end in .bat as it is a batch file.

When you want to save the files in the Newsgator directory, open a command prompt.

Navigate to where you saved the batch file and type in NGBat.

This will copy the files over to the directory.

If you don’t want to type in the code, I have attached a zip file NGBat Files archive. Download and extract to a location.

I have tested it and it works on my machine but as always be careful when running scripts from the Internet.

Hope this script is useful to someone.


Posted by on December 22, 2011 in Programming

Comments Off on Backing up Newsgator files with Powershell