We spend a lot of time in web browsers and if you’re like me, you probably have a gazillion tabs open – your work stuff, your social media sites, sites for e-learning, e-banking, e-commerce, a few blogs, publications and news sites, sites you’re trying to quote material or save useful tidbits from. Suddenly, the browser window freezes or the whole user experience deteriorates to a point where you can’t work any more. This happens regardless of the browser you use – Internet Explorer, FireFox, or Chrome, all of them are equally suseptible to the deteriorating browser-session-from-hell.
Welcome to the cloud!
Or maybe you just updated your computer (or IT pushed out a bunch of updates) followed by the inevitable Restart your computer to finish installing updates message and you’ve hit the Postpone button enough number of times (asking Windows to remind you in 4 hours each time) that the guilt’s really weighing you down. Time to restart, procrastinator!
When closing or restarting the browser-session-with-gazzillion-tabs, you must determine if you’d like to open all the sites in the next session. Browsers do offer to open web pages from your previous session, but the experience has been less than efficient and the feature only works when you restart after a browser crash. In most cases, you’re not sure if you want to open all or any of the pages from the session (and FireFox allows you to select the tabs to reopen after a crash), but you want to store the links temporarily till you have time to decide.
At times like these, I’ve often wished that browsers would offer to save all of my open pages as favorites/shortcuts in a temporary folder and place it on my Favorites/Bookmarks/Shortcuts toolbar that’s always visible. When I restart the browser and have the time, I can take a look at the folder and go back to any pages I may want to or simply file the favorite in the right folder so I can find it later.
Luckily, Internet Explorer does have this feature. In the Favorites menu, you’ll find the Add current tabs to Favorites… option. But it comes with one serious limitation – it only adds tabs from the current browser window. If you have multiple windows open, as I do all the time, you’d have to go through this routine multiple times.
Here’s a Windows PowerShell script to accomplish exactly this.
- Internet Explorer’s Favorites are stored in the Favorites folder in your home directory (by default, C:\users\<username>. Links that show up on the Favorites bar are in a folder called links. The script creates a Temp folder in it.
- Creates folder with today’s date
- Checks if a sub-folder named IE-<today’s date> exists in the Temp folder
- If the folder exists, it appends a number to the new folder name (so it becomes IE-<today’s date>-X, where the number X is incremented for each iteration until the folder name check is false)
- Grabs the URLs from all open Internet Explorer tabs
- Removes any special characters from page names
- Saves them as shortcuts in the folder.
End-result: When you restart Internet Explorer, you can click on Temp > IE-date folder, you can see a shortcut for all pages that were open before you restarted the browser.
-Add – adds all tabs as Internet Explorer favorites
-Full – spits out tabs as hash table that can be manipulated in PowerShell
-Location – outputs name and url
-Content – Retrieves title, URL and content (text in page body)
I didn’t have to write the SaveIETabs.ps1 script from ground up – thanks to a script Alex Angelopoulos wrote. Alex’s version can save all URLs to a text file and reopen them from the saved file next time you start IE. I’ve modified it to save the tabs as IE Favorites and added some usability enhancements.
Some web pages don’t have a title, in which case the URL is used as the page title or has special characters in the page name. This works when displaying in IE and other browsers, but it’s an issue when trying to use it as a file name. Files don’t like to have special characters in their names (although they make an exception for dashes, underscores, dots and spaces). The script parses the file name before saving it and removes any special characters if it finds them.
The fun part was doing the string manipulation using regex, one reason I love the .NET regex implementation (and would like to see support for it in Exchange’s Transport Rules, Exchange Search and Discovery features). See .NET Framework Regular Expressions on MSDN for details.
On the browser wishlist
While on the subject (Hello Internet Explorer and Mozilla FireFox teams!), why don’t the Favorites/Bookmarks bars or menus have a search box? Given we now have a gazillion pages bookmarked, a way to quickly search our favorites – not the entire web, for the web page we’re looking for would be great. There are browser plug-ins and cloud-based services to make managing bookmarks easier, but managing plug-ins (and using cloud services for bookmarks) is another story altogether.
The functionality should be available out-of-the-box in current browsers.