Tuesday, April 24, 2012

How to Batch Rename Files in Windows: 4 Ways to Rename Multiple Files


image
Windows comes with a variety of ways to rename multiples files at once from Windows Explorer, the Command Prompt, or PowerShell. Whether you’re looking for an easy-to-use graphical interface or a powerful command-line method, you’ll find it here.
The Windows Explorer method is fast, but lacking in flexibility. PowerShell is extremely flexible – but it can be intimidating if you’re new to PowerShell. If you’re looking for a powerful graphical interface, a third-party utility is your best bet.

Windows Explorer

Windows Explorer has a quick, built-in way to rename multiple files at once, although it’s pretty well hidden.
To get started, locate the files you want to rename and place them in the same folder. Use the columns at the top of the list in details view to order the files how you’d like them – Windows Explorer will number the files starting from the top at the list.
Select all the files you want to rename, right-click the first one and select Rename. Type your desired base file name and press Enter.
Windows Explorer will take your base name and add a number to each file’s name. This method is good for cleaning up messy names, although it isn’t very flexible.

Command Prompt

You can use the rename – or ren – DOS command in a Command Prompt window to rename multiple files at once. It accepts the wildcard character – * – to match multiple files. The quickest way to open a Command Prompt window at your desired location is to hold Shift, right-click in the folder, and select “Open command window here.”
The most obvious use case for the rename command is changing multiple file extensions at once – something you can’t do in Windows Explorer. The following command will rename all .html files in the current folder to .txt files:
ren *.html *.txt
This command doesn’t offer a lot of power on its own, although it can be integrated into more complex batch scripts.

PowerShell

PowerShell offers much more flexibility for renaming files in a command-line environment. Using PowerShell, you can pipe the output of one command – known as a “commandlet” in PowerShell terms — to another command, just like you can on Linux and other UNIX-like systems.
The two important commands you’ll need are Dir, which lists the files in the current directory, and Rename-Item, which renames an item (a file, in this case). Pipe the output of Dir to Rename-Item and you’re in business.
After you launch PowerShell, use the cd command to enter the directory containing your files. You should put the files in their own directory so you don’t accidentally rename other files.
For example, let’s say we don’t want the space character in our file names – we’d rather have an underscore instead.
The following command lists the files in the current directory and pipes the list to Rename-Item. Rename-Item replaces each space character with an underscore.
Dir | Rename-Item –NewName { $_.name –replace “ “,”_” }
Replace the “ “ and “_” parts of the command to replace other characters in file names.
Consult Microsoft’s documentation on the Rename-Item commandlet if you want  help performing other, more advanced operations.

Third-Party Utilities

If you need a powerful way to rename multiple files at once — without messing with the command line – you’ll want a third-party utility. Jason Fitzpatrick previously wrote aboutBulk Rename Utility, his favorite. Bulk Rename Utility has a cluttered-looking interface that exposes the huge amount of options you’d normally achieve with regular expressions and complicated command-line options.
After installing the tool, navigate to the files you want to rename and select them.
Change some options in one or more of the panels and you’ll see a preview of your changes appear in the New Name column. For example, let’s say we want to remove everything but the number and just have numbered image files. We can set the Remove panel to remove the first 10 characters and the last 1 character.
Click the Rename button to rename the files.

Do you prefer a different batch rename tool? Leave a comment and let us know about it.

Sunday, April 22, 2012

Backup/Copy Files that are "In Use" or "Locked" in Windows (Command Line)


If you’ve ever tried to copy a file that is locked by another application, you’ve probably seen an error message similar to “The process cannot access the file because another process has locked a portion of the file”. So how do you copy it anyway?
image
Since XP, Windows has supported a technology called Volume Shadow Copy, which is used to power the previous versions feature in Vista as well as System Restore and backups. What it does is take a temporary snapshot of the file or drive, and then allow an application to read from the snapshot even while other applications are accessing or modifying the file.
What we can do is use a command line utility called HoboCopy that utilizes this service to copy the file.
Understanding the Prerequisites
HoboCopy and most other backup utilities make use of two services in Windows, and you’ll need to verify that these services are not disabled:
  • Volume Shadow Copy
  • Microsoft Software Shadow Copy Provider
They can be left as Manual startup, so they don’t need to be running all the time. Hobocopy will start the two services automatically when needed, and the Volume Shadow Copy service will be turned back off after it’s done.
Using HoboCopy to Backup/Copy a Single File
The syntax is a little weird, because HoboCopy is really meant to be used for backing up an entire set of folders. We can use it to backup a single file by passing in the filename argument at the end.
Note: on Windows Vista you will need to launch an Administrator mode command prompt by right-clicking on the Command prompt in the start menu and choosing Run as Administrator.
Syntax:
hobocopy c:\directoryname\ d:\backupdirectory\ <filename>
For example, I want to backup my c:\users\geek\mail\outlook.pst file to d:\backups\outlook.pst. Here’s the syntax that I’d use:
C:\> hobocopy c:\users\geek\mail\ d:\backups\ Outlook.pst
HoboCopy (c) 2006 Wangdera Corporation. hobocopy@wangdera.com
Starting a full copy from c:\users\geek\mail to d:\backups\
Copied directory
Backup successfully completed.
Backup started at 2008-03-09 01:57:28, completed at 2008-03-09 01:58:39.
1 files (606.45 MB, 1 directories) copied, 7 files skipped
Using HoboCopy to Backup an Entire Directory
A much more useful task would be to backup my entire User folder, probably to an external hard drive for safekeeping. For this, we’ll want to add a couple of command-line arguments.
/fullCopy all files
/skipdeniedIgnore any access denied messages because of permission errors.
/rCopy recursively
/yDon’t prompt, just copy everything
Syntax:
hobocopy /full /skipdenied /y /r c:\directoryname\ d:\backupdirectory\
Let’s go with the same example, I want to backup my entire user directory to d:\backups\, so I’d use this command:
hobocopy /full /skipdenied /y /r c:\users\geek\ d:\backups\
This command will likely take a very long time to complete, so you might want to take a nap or something. At the end you should have a nearly perfect copy of the directory… if there are any permission errors you’ll be alerted to files that didn’t copy. Realistically any files in your user directory shouldn’t have this problem.
Using HoboCopy to Incrementally Backup a Drive
Hobocopy also supports backing up files incrementally, so it will only copy the files that have changed since the last backup. This works similarly to utilities like rsync, except hobocopy stores the last backup date in a file that you need to specify on the command line.
/statefile=filenameThis flag specifies the file that contains the last backup information.
/incrementalOnly copy files that have changed since the last full copy.
Syntax:
hobocopy /incremental /statefile=filename /y /r c:\directoryname\ d:\backupdirectory\
Example:
hobocopy /incremental /statefile=d:\lastbackup.dat /y /r c:\users\geek\ d:\backups\
The first time that you run this command you will need to use /full instead of /incremental, or else you will get an error because the state file hasn’t been created yet. After that you can run the incremental backup with the /incremental switch.
This would be an excellent way to automatically backup a set of folders as part of a scheduled task.

How to Create a System Image in Windows 7


The new backup utilities in Windows 7 are actually pretty impressive and creating an image will be possible in all versions. Today we take a look at creating a backup image of your machine without the need for a third party utility like Ghost or True Image.
You just just finished installing a fresh copy of Windows 7 on your computer and have it set up to your liking. One of the first things you should do now is create an image of the disc so in the event of a crash you will be able to restore it to its current state. An image is an exact copy of everything on the drive and will restore it back to its current state. It’s probably best to create an image when everything is clean and organized on your system. This will make the image file smaller and allows you to restore the system with a smooth running set up.
Creating an Image in Windows 7
Click on Start go to Getting Started and then select Back up your files.
1-img
Next click on the Create a system image hyperlink.
Decide where you want to save the image. You can choose an external drive, burn to multiple DVD’s, or store it on a network location.
You can include other drives if you want as well but remember that will add to the size of the final image.
At the confirmation screen notice the amount of space the image may take. If something doesn’t look right you can still go back from this point and make adjustments.
A progress meter is displayed while the images is created and backed up. In this example a disk of about 15GB in size took under 20 minutes backed up to an external drive. Times will vary depending on your system and where you’re backing it up to.
After the process is complete you get the option to create a system repair disc which you should do and make sure to save it in a secure location.
When it comes time to restore the image, you will be able to use the System Recovery Options to get the system back.
Image in Windows Vista
Vista Ultimate, Business, and Enterprise allow you to create an image, but Vista Home and Home Premium users do not have the option. The process is similar in Vista, type backup into the search bar and click on Backup and Restore Center.
 
Then click on Back up computer and the wizard will guide you through the process.
 
Conclusion
This is a extremely handy feature and it actually works well. It is also nice that the feature will be available in each edition of Windows 7 instead of just the higher end versions. This will save you some money in not having to spend $50-80 on a third party utility. You should create an image when everything is fresh on your system so the image is not too large and the essentials of you machine can quickly be restored. For instance I created an image after a fresh install and putting Office 2007 and a few of my most commonly used programs. The entire image came in around 10 GB which is easily stored on an external drive or a few DVD’s.

Friday, April 20, 2012

How to Recover Windows and Software Keys from a Broken Computer


Product keys are one of the most important parts of your computer. Unfortunately, most people don’t have them backed up. Here is how you can recover your product keys in case your computer crashes.
The methods described below will also work to backup your product keys before your computer crashes. If you are the cautious type, and you should be, use the tools described below to backup your software product keys before it’s to late.

Copy the needed files

The first think you need to do is recover some files from your broken computer’s hard drive. To do that you can either pull out the hard drive and plug it into a second computer using a spare hard drive connector or use a SATA USB docking station like the one below.
If you don’t have any SATA openings and don’t have a SATA docking station you can recover the files with a live Linux USB drive too. Use whatever distribution you feel comfortable with because you just need to copy a folder to the drive.
If you are using Linux, boot the broken machine from the drive, and copy this folder to the USB drive.
C:\Windows\System32\config
Our config folder was only 140 MB in size which will easily fit on most USB drives. Yours may be slightly bigger but you will need to take into account the ~700 MB of space needed for the Linux files.
Once you have the folder, go to another computer running Windows to use the free utility to recover your keys.

Use ProduKey to Recover Your Product Key

ProduKey is made by our friends at Nirsoft and will allow you to recover your product keys from a running version of Windows just the same as a copied C:\Windows\System32\config folder.
Start by downloading ProduKey from the link below and extract the exe file to a place of your choosing. Launch the program and it will immediately recover the available product keys from your current Windows installation.
Now may be a good time to save your current product keys somewhere safe.
To recover the keys from the broken copy of Windows, drop down the file menu and choose select source.
From the new window select “load the product keys from external Windows directory” and then browse to your saved Windows folder.
If you used a live Linux disk to recover the config folder you will need to manually make Windows and System32 folders and then place your config folder inside of them for the keys to be read.
If you are using a USB docking station, you can also just select “load the product keys of external Windows installations from all disks currently plugged to your computer” and the drive will be scanned automatically.
ProduKey will now show you all the keys it was able to find from your broken computer which makes it very handy when needing to re-install.
To make sure your keys stay safe click the save icon and save a text file of your product keys. We would recommend emailing yourself the text file or saving it to an off site location for safe keeping.

How to Recover Specific Files from a Windows System Image


Windows provides a fail safe way of recovering your entire hard drive with system images, but what if you only need to recover certain files from the image instead of restoring your entire hard drive?
Windows Vista and 7 have a few different options for recovering your computer in case of a catastrophe. System protection will allow you to keep a restore point and backup to an existing known good state, and a system image will allow you to reproduce every bit on your hard drive in case of total failure. A system image is more completed but there is no easy way to recover a single file from a system image.

Create Windows System Image

To get started you first need to make sure you create a Windows system image backup.
Once your backup has been created you will have a series of files on your external hard drive where you saved your backup. The root folder is called WindowsImageBackup with a folder named your username inside. This is where your backup is stored so we are going to use this to get the files back that we need.

Mount VHD

Open your start menu and right click on computer and then open manage.
In computer management click on disk management on the left side.
Open the action menu and select attach VHD.
Note: It looks like you need Windows Vista Enterprise or Ultimate to have this option available. Check out the link below to mount a VHD in Vista Home or Business. If the attach VHD option is greyed out, click in the blank space where your volumes are listed and it should become selectable.
Browse to the VHD file inside the backup folder that was created earlier. If you have two VHD files look at the file size because the smaller one will be your boot partition, and the larger one will be your system (C:) drive.
A new drive should show up in disk management using the next available drive letter.

Recover Files

The autoplay prompt will pop up if you have it turned on because we just plugged in a virtual hard drive.
Browse the files and copy any files you need to recover to your C: drive.

Disconnect VHD

When you have the files you need, go back to disk management and right click on the lower window where it says your disk number. Then select detach VHD to unmount your backup file.
Make sure you don’t check the box that asks if you want to delete the VHD when you detach it.

Mount Virtual Hard Drives the Easy Way

If you think opening disk management is a pain you can instead install VHD attach and open your VHD files directly from your right click menu.
VHD files will be attached to a drive letter just as before and you can recover files the same way.

How To Restore Windows 7 from a System Image


If a major disaster occurs and you find you’re no longer able to boot into Windows 7, you may need to do a recovery. Today we take a look at restoring your Windows 7 machine using a System Repair Disc and a backed up system image.
Note: This article assumes you have already created a System Repair Disc and havecreated a system image in Windows 7.
If you can’t boot into Windows because of a hard drive failure or corrupt OS, you might want to restore your system using the most recent image versus a clean install. In this scenario we are assuming that we’ve exhausted every other option, and the only way to save our system is to restore it from an image.
Boot from System Repair Disc
First we need to boot from the System Repair Disc. Pop it in your CD drive and if the BIOS is already set to boot from CD-ROM first, then you will see the following screen. If you don’t see the Press any key to boot from CD or DVD message, then you’ll need to hit the correct key when booting to pull up the boot options screen and choose your CD / DVD Drive. Usually it’s F12 but each system varies, for instance on my IBM Thinkpad it’s a separate Access IBM button.
1restore
While the System Repair Disc starts up you will see the message Windows is loading files…
After that the System Recovery Options screen comes up. Here you want to choose the correct keyboard input and click Next.
System Recovery searches for the Windows installation(s) you have on the hard drive.
 
Assuming we’ve already tried all of the other recovery tools, we want to select Restore your computer using a system image you created earlier and click Next.
At this screen you can see that it found the last system image which is saved on an external hard drive. If you want to use an older system image, click Select a system imagethen browse through older images until you find the correct one. Because we want everything to be as close to how it was before it crashed, we select Use the latest available system image (recommended) then click Next.
In the next screen just click on Next…there are no other partitions in this instance so we don’t need to worry about excluding disks.
Finally you’re given an quick overview of the selected image and if everything looks right, click Finish.
Click Yes to the warning message that comes up making sure you want to restore the computer with the selected image.
The restore process will begin. It might take a few hours to restore everything depending on the size of the image and how much data there is. Provided there are no errors and the process completes successfully, your system will restart and the system should be restored.
Conclusion
There are a few things to keep in mind when you restore using a system image. An image is an exact copy the hard drive when it was created, so if your last backup was 3 months ago…that will be the drive you’re getting back. All of your programs, system settings, and files are replaced to how they were on the latest system image. It doesn’t allow you to choose individual items to restore, it’s an all or nothing process. This is why it’s a good idea to have your important documents and files saved to a separate drive or network location. The system image will restore your programs, settings, and files as they were when the image was created, but everything else from that point on will be gone. Depending on the date of the system image, allow enough time to run Windows Update, update drivers, patch other software, and tweak everything as necessary. The option to create a system image is available in all versions of Windows 7, and is a great insurance policy to have in case disaster strikes.