Thursday, January 31, 2008

I'm Just Human Folks

Ok, it's corny. But it is also true. I think Windows really is a decent operating system that has mostly lived up to its potential. I think there are some very good things about it. But I also think it really stinks in some areas. So, for my introductory post, I'm gonna talk about one of the stinky areas.

This might seem like a petty gripe, but trust me, one of these days you are going to hit this problem, and you will come back begging forgiveness for your shortsighted disdain. Where am I going with this? Well, thanks for asking. I'm disgusted with Windows handling of moving, copying, or deleting large numbers of files or folders at one time.

One of my favorite movies is "Spaceballs". Besides the fact that Mel Brooks is a comedic genius, putting his kind of comedy together with a spoof on one of the most famous movies of all time goes beyond just mere genius. There was a line in this movie where Dark Helmet was bitching at Colonel Sanders saying "Prepare to depart! Why are you always preparing? Why don't you just go?!" (paraphrased). Followed immediately by the vehicle quickly starting out with Dark Helmet still standing, violently forcing him to sit down.

That is the question I have for Windows. Why are you always "preparing" to delete? Or copy, or move... Just do it!

I cannot tell you for sure exactly what Windows is doing while it is "preparing", though my guess is it has something to do with indexing the files/folders it is about to manipulate. What I CAN tell you is it is beyond maddening to sit there and watch this "preparing" when you have thousands, if not hundreds of thousands, of files or folders to move/copy/delete, and other rather important things to do with your time than babysit this process.

I remember one time when I had about 30 GB of files and folders to delete. I started the process at about 4pm in the evening and it was still in the "preparing" stage when I needed to leave for the day at 6pm. Just for grins I let it go to see how long it might take. When I returned at 8am the next morning it was still "preparing". Not content to simply give up and do the prudent thing (we'll get to that in a moment), I insisted on waiting it out to determine just how long it really would take. Six days. Did you catch that? Six DAYS!!!

Granted there were probably close to a million files and folders in the whole lot (there might have been two million or more; I don't recall for sure right now), but six days? Come on M$, surely we can do better than that? And the kicker is it took two more days for all of the files to completely delete after all that "preparing"!

As it happens, I had a backup of the directory in another location on the same machine. To complete the experiment I did what would have been the prudent thing to do in the first place. If you are an old-timer who is well versed with M$ products, you probably know where I'm going with this. That's right; the command prompt.

Us fogies (I've been working with computers for 28 years now) remember it as DOS. I know, we don't call it that these days because it isn't really DOS. It has matured over the years, while simultaneously having devolved in certain ways. The DOS days really were much simpler, though most folks who use computers these days would vehemently disagree with that. They just don't know how to deal with that blinking cursor next to the "C:\>". Lets talk about that.

There are a few commands that can be used to overcome the pain and agony of this issue. They are relatively easy and most people can figure out the proper way to do this rather simply. A word of warning here, however. By default Windows does not "really" delete files you tell it to delete. It puts them in the "Recycle Bin". The use of the Recycle Bin is another one of my possible theories on why Windows takes so much time "preparing". It is possible Windows is creating some sort of index for the Recycle Bin to use in the recovery option. Like I said earlier, I just don't know. When you delete files from the command prompt, though, no Recycle Bin is involved. The files are whisked away to the bit-bucket, never to be seen or heard from again.

To be fair, though, the files still can be recovered. It is just one major pain in the patukas (that's "ass" for those of you unfamiliar with this technical term). You have to go through an "undelete" procedure that may or may not recover the file, and it usually has an odd character attached to the front of the file name. And it may even be in 8.3 format, which means the file name is truncated in such a way that ensures there are only eight characters in the name of the file and three characters in the extension. The bottom line here is if you are going to use the option I outline here, make sure you REALLY want to delete all of these files. Copying or moving files is less risky as you are not telling the system to actually remove anything.

Down to the nuts-and-bolts here (that's another technical term):

1. To open the command prompt, click on the Windows "Start" button and select "Run". Type the letters "cmd" (without the double-quotes) on the Open line and click OK. You might have noticed that there is a shortcut in the Start menu for a command prompt. It's OK if you just click on that as well. It is the same thing.

2. You are now faced with the daunting command prompt cursor. Based on certain settings within Windows, it may look something like this:

C:\Documents and Settings\{LoginName}\> _

Where "LoginName" is the account name you use when you log into Windows. You may not "think" you are logging into Windows with any account name because when you turn your computer on it just boots up straight to the desktop. Well, this is a feature (one I really like for most home users), but Windows still uses a user account and goes through a login procedure. The password is blank in these cases, except for Windows 2000 Professional users. In the case of Win2k Pro, the password is saved internally and filled in for you automagically when the login process runs.

3. Here comes the tricky part. You need to determine where the files are that you want to delete, and you need to ensure that the command prompt has been told to go to that location before starting the delete process. This is not strictly necessary as you could simply type out full paths when executing the deletion command, but that is a real pain. It is especially troublesome if you keep mistyping parts of the command line or have to worry about paths that have spaces in them. Easier to just change to the path you will be deleting from.

One of the other things that can be tricky about using the command prompt is making sure you are at the proper drive or disk partition, not just the proper folder. So for our example we are going to assume there is a second partition on the hard drive that is used to store data files, and change to that partition. In this case the files we want to delete reside in the "D:\Data\Big Application\manyfiles" directory.

We know the path because we opened "My Computer" and used Windows Explorer to drill into the folder where we wanted to delete the files, and looked at the path in the address bar at the top of the Window. What's that you said? You don't have an address bar in your Windows Explorer window? Click on View, then Toolbars, then Address Bar. You now can see the address bar. Uh oh, still can't see the full path? Click on Tools, then Folder Options, and select the View tab in the Folder Options dialog box. There is a list of check-box items in th bottom half of this dialog box. About four or five items from the top will be a setting for "Display full path in the address bar". Check this box and click the "OK" button. You should now see the path in the address bar.

Based on the path in our example, the first thing we need to do is change to the partition that the files are located on. This is really rather simple. Just type in the following:

d:

and press Enter. The command prompt is mostly case insensitive, so it doesn't matter if you use a capitol "D" or a small "d". There are some exceptions to this rule, but they are rare and will not be covered in this post.

Now that we have selected the D:\ drive we need to change to the folder that we wish to delete the files from. In this case we would type in the following and press Enter:

cd
Data\Big Application\manyfiles

Notice there is a space between "cd" and "Data". I continue to use the same case here for readability. It is not necessary to use the exact case. Also, there is another method of changing to the appropriate directory. You would type in the following lines, pressing Enter after each one:

cd Data
cd Big Application
cd manyfiles

Obviously the first one is simpler, but it can be frustrating if you keep mistyping a character and getting the dreaded "path not found" error. However, it really isn't all that bad because you do not need to retype everything. Just press the up arrow on your keyboard and the last command you typed will repeat itself. Use the arrow keys and delete key to make any corrections and press Enter again. It does not matter if you move the cursor to the end of the line before pressing Enter either. The cursor can be anywhere on that line, even right in the middle of what was typed, and it will still execute the command in the same way.

4. Now we have the command prompt pointed to the "D:\Data\Big Application\manyfiles>" directory. We want to delete all of the files in this directory and all sub-directories, of which there are many thousands of each. To perform the file deletion, type in the following and press Enter:

del *.* /s /q

If you type in "del /?" you will get a listing of all of the available options for the delete command. In this case we are using the "this directory and all sub-directories" option with the /s switch, and the "don't prompt for action when an error occurs or a wild card is used" option with the /q switch. That's not how the help describes them, but I like my descriptions a bit better. I'm afraid I'm biased in that regard, though.

This may take a while depending on how many files there are to delete. You can simply minimize the command prompt window and continue on about your business, checking back on occasion to see whether or not the task has completed. Depending on the speed of your computer, the process might slow things down a bit. With todays speed for both the CPU and hard drives, it shouldn't be too bad. Do notice, however, that there is none of this "preparing" business. The command goes right to work just deleting the files. Nice, eh?

5. All right, all of the files are deleted now, but the directories are all still there. That's ok, we have a plan for that too. We type in the following and press Enter:

rd /s /q "D:\Data\Big Application\myfiles\."

Yes, I know, the question is "why did I have to type in the entire path this time?" Well, the "rd" command (stands for "remove directory") is a bit pickier about how it works. Technically you should be able to just type in "rd /s /q "*." from the location the command prompt is currently at, but I always seem to have trouble getting this to work properly. I could just be dense. But I know that typing in the full path works good, so that's what I recommend. In a future post I will discuss a shortcut that avoids all that typing.


It should be obvious by now that I really am fond of using the commanpt prompt. In fact, I do so whenever possible. My current j.o.b. is in technical support, so I get a chance to use the command prompt on a regular basis. This really is a very powerful option in Windows, and I would encourage anyone who uses a computer to learn how to perform nifty manipulations with the command prompt.

My next post will cover copying and moving. I will try to include pretty pictures in the next post so you can see exactly what the commands are as well as the results. In the near future I will also discuss how wild cards work, how to list files, and even the settings to change the colors for the command prompt. After that I will launch discussions on creating batch files to automate some tasks and get deeper into some of the additional commands that can be helpful in the chores that need to be done in Windows.

As the title of this post indicates, I am only human. I make mistakes and have (on occasion) been incorrect about a thing or two. As a result, I ask... nay, I beg of you, please feel free to correct, criticize, or comment on anything I put in here. Feedback is most welcome.

Until next time, have a wonderful day. Cheers!

No comments:

About Me

5'9", dirty blond hair that's going gray, workaholic, lazy bum. Well, that last part mostly has to do with housework. I hate cleaning the house. I'm a bit of an introvert, though I do have my extroverted moments and can force myself to be such if the situation requires it. Been divorced twice, have four children (all girls), and not much of a life. I keep swearing to myself I'm going to get one of those. Oh, did I mention I'm a horrible procrastinator?