Thursday, February 7, 2013

Rename multiple files in a directory / Replace part of a filename in multiple files


Hi All,

This morning I was generating some scripts out of SSMS and it had some wired names attached to it. I wanted to rename them all manually, then it occured that if I write a Powershell script, I could reuse this code for something else in future.. So, here it goes:

Running the script :

PowerShell

[If you get errors, use Set-ExecutionPolicy cmdlet to set the correct permissions]

_______________________________________________________________________
#Script to remove / rename part of filenames on multiple files..
 

$a = $args.length

if($a -eq 3)

{
$workingfolder = $args[0];
$pattern = $args[1];
$replacetext = $args[2];
}
else
{
write-warning "No. or arguments invalid. Usage: "
break;
}

function Recurse([string]$path) {
$fc = new-object -com scripting.filesystemobject
$folder = $fc.getfolder($path)
foreach ($i in $folder.files) {
$path=$i | select Path
$path = $path -replace "@{Path=",""
$path = $path -replace "}",""
$name=$i | select Name
$name=$name -replace "@{Name=",""
$name=$name -replace "}",""
$name=$name -replace $pattern,$replacetext
Write-Host Renaming $path to $name
#Write-Host $name
Rename-Item $path $name
}
foreach ($i in $folder.subfolders) {
Recurse($i.path)
}
}

Recurse($workingfolder);
_______________________________________________________________________

Friday, February 1, 2013

You already have read all the blogs and reviews of Win 8, Here is my take on Win 8




You already have read all the blogs and reviews of Win 8, but are you still thinking whether the $40 worth the upgrade? Unlike the other bloggers, I waited whole two weeks with Win 8 on my two laptops and then decided to discuss the Good/Bad of Win 8. Well, here's an end user’s take on Win 8.

Good :

Bitlocker Rocks:

If you are like me, who travels with laptop a lot, you will always be afraid of losing it. Worse, what happens to the confidential documents, if it falls in wrong hands? Previously with Vista and 7, you need to have the Ultimate edition to enable the bit locker. Not anymore. You can do it with win pro edition itself. The advantage of using bit locker instead of programs like true crypt? You can backup the key to your MS account and it makes recovery easy.


TaskManager rules:

The new TaskManager is more than just TaskManager. You can disable the unwanted startup programs, look what program is using the disk etc., It even color codes the resource intensive programs so that you can kill it as needed.


The new Start menu is brilliant:

Some people might be angry with the start menu, but I absolutely love it! The ability to get live updates, like news and weather by just pressing the win key. Don't have to launch the browser, don't have to add the stupid gadgets etc., It is absolutely brilliant.




Parental Controls:

If you have kids, then you can configure the rules right from the user accounts in Win 8. Eventhough this is an upgrade of Windows 7 parental controls feature, this is a worthy upgrade.

Low memory foot print:

When comapred to Win 7, my laptop took 300 MB less! I did the math, looks like win 7 on cold boot takes about 2.1 G's. Where as, my Win 8 is taking only around 1.7 G's.

Speedy boot time:

Compared to Win 7, My laptop appears to be starting really fast. Well, this comes at an expense. Read my disadvantages section.

Super Easy upgrade process:

Upgrading from XP/Vista/7 is super easy. You just download the compatability checker, run it, put in your billing details and it takes care of the rest.

Automatically detects Networked printers and installs the drivers:

I have a networked MFC and a smart TV, all were detected automatically and drivers were installed automatically. It was cool.

Windows Defender is turned on by default:

You don't have to go to the MS website and install security essentials. New Windows Defender replaces the Security essentials and it is on by default.
Bad:

Now that we have seen the good things, my take on top annoyances of Win8.

Inconsistent behavior of Start menu :

Unlike most of the others, I actually LIKE the new start menu. One minor annoyance is that, when you log in for the first time, you need to press Winkey + D to actually minimize it. On the subsequent visits, you can actually use “Esc” key to minimize the start menu. Why is that? I have pinned all the required apps on Task bar, so I rarely use it.

Shutdown is not really a “shutdown”:

My laptop is very old and even though sleep and hibernate works fine most of the time, there is a h/w issue with it's motherboard, it will cause the resume of sleep and hibernate fail. With Win 8, If I select Shutdown from UI, it goes to this “hybrid” shutdown, which just logs you off and turns to hibernation. It took me a while to figure out and I have to issue shutdown -s command to shut it down “cleanly”. I am yet to find and alternate for this issue.

Hyper V is not supported on older Intel processors:

This by far has been my biggest issue. Hyper V requires a processor, capable of SLAT. Why??? My older Core2 duo has hardware assisted virtualization, but it doesn't have SLAT. All I need to do is to run a simple Win 7 instance for my personal projects and I had to go with Virtual Box.

Win XP Mode is not supported on Win8:

Even if you had upgraded from Win 7, you still cannot use the old Win XP virtual mode VHD's to boot in Win 8. I managed to use Vmware's converter tool and convert it to VMWare's format, but it is now saying that my Windows XP license is not valid and it is asking for a product key.

Moving the mouse to the corner of the screen behaves inconsistently:

When you move your mouse pointer to any corner of the screen, a menu with options is supposed to show up. On one of my laptops, I have dual monitors. When I try to get to the shutdown from my primary monitor, the bottom right corner doesn't seem to work consistently. Sometimes it shows the options menu as expected, but most of the time it doesn't do anything.

Security Permissions tab has been changed in Win 8:

If you like me, play with the permissions a lot, You have to get used to the new permissions tab. If you need to change permissions on a folder where you are not the owner. You will need to change the ownership (including sub-folders) and then do the permission propagation. In Win 8, you need to select two check boxes to propogate the permissions. See the screenshot below:




Confusing User add screen:

Once you add a couple of users, you will get used to it, but initially adding users is confusing. I wanted to set up a local account and couple of Microsoft accounts to the PC. That's the easy part. But if you want to make the newly added account admin, you need to go to control panel to change the user type. Why not ask the user type at the new user creation screen itself? Why not add a “Advanced” setting link here?


Default Music Player/ Video Player/Picture viewer / XPS Viewer sucks/ any viewer:

If you had purchased a PC with Win 8, the manufacturer would have modified this behavior, but if you, like me had installed Win 8 from scratch, all the default apps sucks big time. The default viewers are based on Modern interface (Formerly metro). I had to change those using file type associations manually. Why not detect the PC type (Touch/Non-Touch) and preselect the appropriate app? How hard is that?


There is no indication that your Graphics card has been detected properly and installed:

In Win7, I had an option on the assessment screen which would warn if the driver is not installed. Even though my card's driver was downloaded automatically through Win update, a notification would have been nicer.


IE 10 launched from start menu, went to full screen mode by default:

Why? I was able to quickly revert that back to desktop mode, but most of users might have found it confusing, had they encountered it.

IE 10 doesn't have compatability mode:

Why? IE 9 has it.. Even though the sites render properly, I don't know why MS removed this option.

Media center requires a separate key:

Why? If you are planning to drop a particular product, why not just do it? I am being forced to go to a separate site, apply for a key, wait for 24 hrs to get the key? To me its an unnecessary hassle.

Mordern apps don't adapt to devices without touchscreen:

This is a big oversight on MS's part. They could have rigged the install such that if a laptop doesn't have touchscreen, it should automatically disable the touch functions. When I drag the “Mordern” apps using my mouse, it behaves wired. Sometimes the snap comes up. I have to press Alt + F4 to close it. There is no way I could just use mouse to navigate.
Eg:
There is no close button, I have to use key board to close it...The Mouse gestures are funny. You need to move your mouse to top left to choose other apps. Why ???