Rename Multiple Restored Avamar SQL BAK Files

This entry was posted by on Thursday, 5 January, 2012 at

This is a simple one liner that can be used to rename the default Avamar SQL Restored BAK from f-0 for multiple databases.

The Problem:

When restoring a database to a BAK file from Avamar it automatically restores the file into a folder named the Database and a file called “f-0”. That isn’t very helpful, especially if you have multiple databases you have restored. So I wrote a one line powershell script that you can use to rename every BAK file to the name of the database.

Get-ChildItemC:\RestoredDBs\ | foreach {Rename-Item-Path“C:\RestoredDBs\$_\f-0”-NewName“$_.bak”}

Script Steps:

1.       Make sure and change the directory where your restored BAK files/folders are located.

2.       The script just gets a list of all the directories in the folder and then performs a rename on the file inside called “f-0” to the foldername.bak.

3.       E.g., I have a database that I restored located at C:\ResotredDBs\DB1. Inside of this folder you have a file called “f-0”. This script will rename the “f-0” file to DB1.bak.

Hopefully you find this useful.

~Lane


Leave a Reply