I was looking for some good tech talks to download for the weekend and came across “Techdays 2012 the Netherlands”. I went ahead and downloaded a few of the videos using the Firefox extension “DownThemAll”.
Once the downloads were complete, this is what my folder contents looked like:
That was as expected, but I’d rather prefer the names to be just the names of the talks without the Techdays….. prefix. And, I wasn’t really keen on renaming each one of them by hand, coz I plan to download more
PowerShell was the first thing that came to my mind for automating this. After a bit of binging around for syntax, I started off and came up with this script:
$files = ls -name -exclude *.ps1
foreach ($f in $files)
$d = [regex]::split($f, 'Netherlands');
Rename-Item $f $d
At this point, I went all philosophical, thinking “Sometimes, it’s the little things in life that makes you happy”
And, I’m new to PowerShell – this is my second “useful” script (I’ll blog about the first one shortly). I’d love to learn more about it and would like to hear from you, Dear Reader, if you would have written this script any differently.
Thanks for reading!
PS: You can follow me on twitter at “_amarnit”, where I share some quick tips/learnings at times!