Showing posts with label shortcuts. Show all posts
Showing posts with label shortcuts. Show all posts

Sunday, December 11, 2011

Moving Bookmarks to the Start Menu

I was using Firefox 7.0.1 in Windows 7.  I had created a customized Start Menu that contained not only the shortcuts to installed programs, but also the full contents of portable programs.  I had saved that Start Menu to a drive other than drive C, so that it would survive if I reinstalled or upgraded Windows.  So then my preferred arrangement of shortcuts and programs in my customized Start Menu would also survive.  I could also carry it around on a USB thumb drive and use it on other computers, at least for my portables and for those installed programs that they had installed in the same (default) locations on drive C.

In Firefox, I had a lot of bookmarks. (If I'd had them in Internet Explorer or some other browser, I probably could have imported them into Firefox.)  I wasn't really happy with my existing bookmark arrangement.  It occurred to me that I could incorporate the bookmarks into my custom Start Menu.  That way, my bookmarks would be portable too, and my web-based tools would be in the same place as my installed and portable tools.  Within the Start Menu, I could then sort the web links into subfolders.  For instance, the ones that had to do with multimedia could go into the Multimedia folder along with my image editing programs.  This would eliminate the task of coordinating bookmarks among various browsers.  Also, when I discovered a cool new bit of freeware that I didn't actually need right then, I wouldn't have to download and keep a copy that would eventually become outdated, or that I would forget what it did or why I had ever downloaded it in the first place.  Instead, I could just put into my Start Menu a link to the webpage that explained the program.

There would be some drawbacks as well.  It might be harder to detect duplicates in some cases.  Also, I might have to drill down through more levels of a Start Menu than of a Bookmarks folder to get where I wanted to go.  Still, since my existing approach to bookmarks did not work, I decided the advantages of a new approach would probably outweigh the disadvantages.

I didn't want to convert my bookmarks into a single HTML file.  As I had previously learned, such a file would have required constant updating and rearrangement, so as to put links in the desired order.  To clarify, the idea was taht I would save the bookmarks as individual links (shortcuts) that I could see in Windows Explorer.

To make that happen, I tried using the Bookmarks manager in Firefox (Bookmarks > Show All Bookmarks).  I found that I could cut and paste, or drag, individual bookmarks from the manager (or from the Bookmarks toolbar) to the Start Menu in Windows Explorer.  But if I tried to move multiple bookmarks at once, it didn't work.  The manager didn't give me an option of exporting bookmarks as individual link files.  There also didn't seem to be any way of bulk-handling Bookmark subfolders containing bookmarks.  I searched and saw various suggestions and requests involving other browsers, but as far as I could tell neither Chrome, Opera, nor Internet Explorer had an option to mass-export favorites or bookmarks as individual URL files.  A search of Firefox add-ons yielded nothing.

Some of my bookmarks were years old.  Before exporting them, whether in bulk or individually, I wanted to verify that the bookmarked website was still active.  To do this, I used the CheckPlaces add-on.  I had to go into the Firefox > Tools > Add-Ons menu to run it.  Within maybe five minutes, it concluded that I had 4,325 bookmarks; and of those, it said I had 1,395 duplicates.  This was not a surprise; my bookmarks folder was a screwed-up accumulation of years of repeated attempts at organization.  I told CheckPlaces to delete all duplicates.  For the other errors it found, I canceled out and went back to the CheckPlaces starting menu.  I changed Concurrency from 10 to 5, in case my relatively slow Internet connection was producing false errors in attempts to reach webpages.  I turned off "Load favicons" and ran it again.  Oddly, it still found 1,395 duplicates within 4,325 total bookmarks.  There wasn't a user's manual.  It turned out that I had to click the OK button to make the deletion permanent.  I did that, and then ran CheckPlaces again.  This time, it found only 1,711 bookmarks.  That didn't add up.  When I told it to delete duplicates, did that mean it deleted all copies of a duplicated bookmark?  Just then, Xmarks popped up and told me that my set of bookmarks on the computer was significantly smaller than my backup set on their server -- but they said I now had 1,866 bookmarks, not 1,711.  I decided to download the Xmarks backup and start over with CheckPlaces, this time paying closer attention to what it was deleting.  Spot checks suggested that it had done the sensible thing and deleted duplicates, but not all copies -- that is, if A and B matched, it looked like it deleted only one of them, not both.  So that was good.  The larger-than-expected number of deletions appeared to be due to the fact that I had three or more copies of some bookmarks.  Next, the CheckPlaces list of supposedly "Questionable" websites seemed to called for manual inspection: some were indeed duds, but others weren't. But then it looked like a webpage had to return a 301 error in order to get onto that list; and I found that a 301 error meant that the page had been moved but that there would typically be a forwarding address. So I ran the option, in CheckPlaces, to Fix All 301s.  Spot checks (and the age of many links) also suggested that I might just go ahead and delete the ones that CheckPlaces had identified as Failed for one reason or another.  I reran CheckPlaces a couple of times, deleting a few more duplicates and failed links.  In my final run, my original set of 4,325 bookmarks had shrunk to 1,322 -- still a lot, but more manageable.

So I had somewhat shrunk my list of bookmarks.  But I still had the main problem of getting them from Firefox to Windows Explorer.  How was I going to do that?  I thought of opening the bookmarks and then copying from the History manager instead, but in Firefox 8.0.1 that behaved the same as the Bookmark manager. Another possibility might have been to go ahead and export the bookmarks to an HTML file, one per bookmark folder; use Snap Links or Multi Links to open all of the links on that page; and then drag the icon from the Firefox address bar to the appropriate Windows Explorer folder, for each webpage that opened successfully.

But then I discovered that the Firefox bookmark manager (Bookmarks > Show All Bookmarks) would allow me to do the same thing more easily.  For the bookmarks that were in the Bookmarks Toolbar, I could select a bunch of links within a folder, right-click on them, and choose Open All in Tabs.  This way, I could see what was in those webpages, and decide if I really needed to save a link to them (using the same approach of dragging the link to Windows Explorer).  Then I could delete those that I had opened, and thereby gradually whittle down the accumulated mess that my Firefox bookmarks had become.  If I wanted to have a list of bookmarks in Firefox, I would still have the option of recreating it by opening and bookmarking a bunch of links from the Start Menu.

So I dragged all my bookmarks to the Bookmarks Toolbar and began opening them and manually dragging links to a single folder that I called "Unsorted Bookmarks," from where I would further sort them into various places in my Start Menu.  I decided that I would probably do a better job of this if I did it gradually, sorting just a few bookmarks at a time, paying careful attention rather than racing through it.  So I added a line to a batch file that was scheduled to run regularly on my computer.  That line would open a Windows Explorer session focused on that Unsorted Bookmarks folder, as a reminder to me.  So now, every day or week or however often I had scheduled that batch file, that Windows Explorer session would be one of the things that would start up, reminding me that it was time to examine another 10 or 20 bookmarks in Firefox.  At this point, then, it seemed that the project was pretty clearly in view, and it would just take a while to finish.

Tuesday, July 5, 2011

Finding and Removing Dead Program Shortcuts

In Windows 7, I had moved my Start Menu to a folder on drive W.  This protected the Start Menu in case of Windows reinstallation, and made it available for regular backup on the same basis as everything else on drive W.  It could also be shared on a network.

That relocated Start Menu contained all the shortcuts normally found in a start menu.  I had since uninstalled some of the programs to which those shortcuts pointed.  There were a lot of programs, and a lot of shortcuts.  I wanted to find a way to automate the process of going through that folder and detecting the shortcuts that didn't work anymore. 

This post describes the start I made toward that effort.  The post is terminated prematurely.  I did not record the event leading to that termination.  I think I may have reinstalled Windows at that point.

I began with the assumption that the files I was looking for were .lnk files.  That is, I decided to disregard .url or any other kinds of link or shortcut files; I wanted only those that would link to an executable program on my computer.  This did not appear to be a major limiting assumption:  a quick look suggested that only a small number of files in the Start Menu were .url links.

On that assumption, in a CMD box (Start > Run > cmd), I went to the root of the Start Menu folder (using CD W:\) and ran a command to get a file list:

dir *.lnk /s /b /a-d > dirlist.txt
In the resulting dirlist.txt file, I found lots of lines with entries like "W:\Start Menu\Programs\Miscellany\Games\Freecell.lnk."  I copied the contents of dirlist.txt into a Microsoft Excel 2003 spreadsheet.  I added an index column at the far left, so as to number each filename that I had gotten from dirlist.txt.  I gave the files odd numbers.  For example, in cell A2 I typed this:  =A1+2.  I copied that all the way down column A.  So the consecutive rows were numbered 1, 3, 5, and so forth.  I made the numbers permanent by using this sequence:  highlight all numbers; Edit > Copy; Edit > Paste Special > Values.  (Alt-E would bring up those options in newer versions of Excel.)  Now cell A2 just contained the number 3, with no underlying formula.

I copied that worksheet into a second worksheet in the same Excel file.  Here, I replaced the numbers with even numbers.  So in this worksheet, cell A2 contained the number 4.  I named the first worksheet "Odd" and the second worksheet "Even."  I did this so that I could eventually combine the two worksheets into a Combined worksheet, and the numbers would sort in the correct order on that first column in the combined worksheet:  1, 2, 3 ...

In the Odd worksheet, I wanted to produce batch commands that would give me the name of the file we were talking about.  For this purpose, cell A1 contained the number 1, cell B1 contained a file and path name like "W:\Start Menu\Programs\Miscellany\Games\Freecell.lnk," and now cell C1 would contain this formula:  ="DIR /s /b /a-d "&CHAR(34)&B1&CHAR(34)&" >> output.txt."  The CHAR(34) would produce quotation marks that Excel would not misunderstand.  This formula produced a value in cell C1 like this:
DIR /s /b /a-d "W:\Start Menu\Adobe Acrobat.lnk" >> OUTPUT.TXT
I copied that formula all the way down column C, so that I had a whole series of commands to type the names of each link or shortcut file into the OUTPUT.TXT file.

Now I wanted OUTPUT.TXT to contain the file's contents after its name.  These link and shortcut files were typically pretty small, so I felt I could just put it all into the same OUTPUT.TXT file.  To get the file's contents, I went to the Even worksheet.  The command that I put into cell C1 in that spreadsheet was the same as the one quoted above, except here the command was TYPE rather than DIR (and had no /s or other parameters).  This would actually type the contents of the file into the tail end of OUTPUT.TXT.  Here, again, I copied the formula all the way down the worksheet.

With that done, I could combine the Odd and Even worksheets into a Combined worksheet.  I sorted the Combined worksheet on the first field, by the index numbers.  So now I had a list of paired commands, a DIR and a TYPE command for each .lnk file in my Start Menu.  So the first two resulting entries in this Combined worksheet looked like this:
DIR /s /b /a-d "W:\Start Menu\Adobe Acrobat.lnk" >> OUTPUT.TXT
TYPE "W:\Start Menu\Adobe Acrobat.lnk" >> OUTPUT.TXT
After running those two commands, OUTPUT.TXT contained gibberish looking somewhat like this:
W:\Start Menu\Adobe Acrobat.lnk
L        À      FÉP                                                     Ó PàOÐ ê:i ¢Ø +00 /C:\                   R 1     ¬>X~0 Windows < ï¾î:£ ¬>X~*   'ó                   W i n d o w s   X 1     ²>Í1 INSTAL~1  @ ï¾!>&y²>Í1*   ñ©                   I n s t a l l e r   ’ 1     ²>Í1 {A4EF1~1  z ᆵ> §²>Í1*   ô    
              { A C 7 6 B A 8 6 - 1 0 3 3 - F 4 0 0 - 7 7 6 0 - 0 0 0 0 0 0 0 0 0 0 0 4 }   h 2 ˜  ²>Í1! _SC_AC~1.EXE  L ï¾²>Í1²>Í1*   gz                   _ S C _ A c r o b a t . e x e      W . . \ . . \ . . \ . . \ . . \ W i n d o w s \ I n s t a l l e r \ { A C 7 6 B A 8 6 - 1 0 3 3 - F 4 0 0 - 7 7 6 0 - 0 0 0 0 0 0 0 0 0 0 0 4 } \ _ S C _ A c r o b a t . e x e K C : \ W i n d o w s \ I n s t a l l e r \ { A C 7 6 B A 8 6 - 1 0 3 3 - F 4 0 0 - 7 7 6 0 - 0 0 0 0 0 0 0 0 0 0 0 4 } \ _ S C _ A c r o b a t . e x e      34TL`aMnKwUK&!!'L?@$ViewerProgramFiles>c%TW.h=LK?6-6ht!be8]                                                                                                                                                                                                         3 4 T L ` a M n K w U K & ! ! ' L ? @ $ V i e w e r P r o g r a m F i l e s > c % T W . h = L K ? 6 - 6 h t ! b e 8 ]                                                                                                                                                                                                                                                                                                                                                                                                                        %SystemRoot%\Installer\{AC76BA86-1033-F400-7760-000000000004}\_SC_Acrobat.exe                                                                                                                                                                                       % S y s t e m R o o t % \ I n s t a l l e r \ { A C 7 6 B A 8 6 - 1 0 3 3 - F 4 0 0 - 7 7 6 0 - 0 0 0 0 0 0 0 0 0 0 0 4 } \ _ S C _ A c r o b a t . e x e
In other words, I had a link named "Adobe Acrobat" in W:\Start Menu, and that link connected with a file called _SC_Acrobat.exe in the "%SystemRoot%\Installer\{AC76BA86-1033-F400-7760-000000000004}" subfolder.  (The folder named %SystemRoot% would ordinarily be the C:\Windows folder.)  There no longer was any such subfolder, so this particular link was bad.  The challenge for me would thus be to extract those file and directory locations from OUTPUT.TXT, and test them to see which ones led to actual files and folders.

To extract the file and directory locations, I copied the gibberish of OUTPUT.TXT into Word 2003, and saved it as OUTPUT.DOC.  As shown in the gibberish example above, it appeared that extra spaces were added among many characters.  I searched OUTPUT.DOC and verified that there were no occurrences of @@@.  I did a find and replace in Word, replacing three consecutive spaces with @@@.  I repeated that until there were no more occurrences of three consecutive spaces.  Then I replaced all occurrences of two consecutive spaces with ### (also verified not to be present previously).  Next, I replaced all single spaces with nothing.  That is, I just eliminated them.  Now I could convert ### back to two spaces and all occurrences of @@@@ (since there had been a huge number of extra blank spaces) to just three "at" symbols (@@@).  I had to repeat that one a number of times.

Friday, September 17, 2010

Windows XP: Integrating the Start Menu with a Portable Apps Tree

I had come up with a tentative list of portable applications to use in Windows XP, and had arranged the program folders for those apps in a tree structure under five main categories:  Multimedia, Online, Productivity, Tools, and Miscellany.  The question for me was, how do I combine that hierarchy with the similar hierarchy that I used for the shortcuts in my Windows XP Start Menu?

That question arose because, if the two weren't combined, I would have to search in two separate places for a program that I wanted to run.  First, I would search my Start Menu; and then, I would search my set of portable apps.  Portable apps were, almost by definition, not ordinarily installed on the computer, and therefore did not tend to create their own shortcuts in the Start Menu.  So unless I created shortcuts for my portable apps (and went through the hassle of keeping the shortcuts up to date with the actual portable apps that I was finding and using), I would have the set of shortcuts installed in the Start Menu by the installed programs, and then I would have the separate set of portable apps.

(There were alternatives.  I had recently seen a program that would let me list the programs that I wanted to run, regardless of where they might be.  But that program hadn't looked very appealing to me.  Even if I didn't absolutely have to have a single set of programs and shortcuts, that was what made sense to me at this point.)

The concept, here, was that I would wind up with a single hierarchical Start Menu that would contain all of the shortcuts to my installed programs, plus all of the program folders for my portable apps.  Obviously, I would not want this to reside on drive C, where all my portable apps would be wiped out whenever I reinstalled Windows.  I had already moved my Start Menu to drive D.

The simple answer, of course, was just do it -- just combine the two, there on drive D.  The result would be relatively portable, as long as the machines where I used it would all use the default locations for program installation.  That is, the portable apps would run wherever -- I would be clicking directly on their executables -- and the shortcuts to installed programs would run too, as long as they were always installed in the same places, so that the shortcuts on my Start Menu could find them.  On machines where some programs weren't installed, or weren't installed in the right places, the shortcuts would simply fail to run.

With this plan in mind, I organized the combined set of portable app program folders and shortcuts into a single tree.  To get the system to see them, I added this to the registry:

; Set locations for Start Menu and special folders
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders]
"Start Menu"="D:\\Installation\\Start Menu" 
"Programs"="D:\\Installation\\Start Menu\\Programs"
"Startup"="D:\\Installation\\Start Menu\\Programs\\Startup"
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders]
"Start Menu"="D:\\Installation\\Start Menu" 
"Programs"="D:\\Installation\\Start Menu\\Programs"
"Startup"="D:\\Installation\\Start Menu\\Programs\\Startup"
"Administrative Tools"="D:\\Installation\\Start Menu\\Programs\\Miscellany\\Administrative Tools"
 

With that registry change, right-clicking on the Start button and choosing Explore would open a copy of Windows Explorer in the new Start Menu location on D.  It did not work that way with right-clicking Start > Explore All Users, though.  That just put me in the traditional Start Menu location (C:\Documents and Settings\All Users\Start Menu).  I also found that additional program installations would put their Start Menu icons in the traditional location, and I would have to move them over to the new location by hand.  So apparently there were still some rough edges to smooth out.

Generally, though, I had the result I wanted.  I had a Start Menu that would not only be preserved on drive D when I reinstalled Windows, but would also be portable.  The programs on it would run on any machine, as long as either (a) they were genuinely portable apps (i.e., I was clicking on their executables) or (b) they were installed in the default locations on the computer where I was using this Start Menu.