Friday, April 11, 2008

Powershell renaming filenames

One of the problems that I frequently come across is the need to rename a bunch of files according to a certain pattern which involves numbers. Now I still haven't figured out how to do that yet but I've just seen a Powershell Blog post Managing Datacenter Machine Names that gives me enough information to work it out - I think.

The cool new feature that I've just discovered is the range operator in Powershell:

1..5

Will generate the numbers 1 through 5. Pipe this into your command and use some .NET formatting and you can get zero padded numbers to help rename, copy, move, delete files that will save a lot of time on large folders of files.

No comments:

Post a Comment