Now why, you ask, would you ever find yourself in a position to copy a very large amount of files from one place to another? Good question. Let's think about this one for a minute {insert Jeopardy theme here}. Ding. Time's up.
Ever thought of buying a new computer? What about all of those files on your current system that you want to keep? Where did you put all of them? Wow, it could take hours and hours to track those bad boys down. If you are anal-retentive and always organized your files neatly, this won't apply to you (maybe). For the majority of us, though, it's a bitch. (This reason is just one example. There are many others that could be explored.)
There is a fairly easy and comforting solution to this. Go spend $90 at your local discount computer hardware store and pick up an external USB hard drive. Make sure the capacity meets or exceeds what you have on your computer. Now, dump every last file on the hard drive in your computer onto the external. When you get the new computer, you can pick and choose what you put back, always knowing that external is there with all your files in case you remember something you needed.
While I realize this is a shotgun or meat ax approach, it sure saves a lot of time and anxiety. Frankly, disk space is cheap these days, and if you really want to go back and clean all the unnecessary files off the external drive and use that space for, oh I don't know, all those extra porn vids you have, that's peachy. But this gives you all the time you want to take to get it done. On the other hand, you are just slobbering over that new PC you just bought, and really want to put it through it's paces, so this is probably going to be the surest way of making sure you don't miss something important before tossing the old machine in the garbage; or better yet, donating it to a worthy cause.
Herein lies another one of Windows most annoying "features". One of the most frustrating elements of copying any more than one or two files from one place to the other within Windows is when there is a file lock on one of those files. A file lock occurs when another application or the operating system itself is currently using a file, and will not allow you to copy, delete, or move said file. If you select a block of files and Windows hits one that has a file lock on it, an error message comes up saying that it could not copy/delete/move the file, and the only option is to click "OK". At that point the process you were going through simply stops. No way around it. That's it. That's all. You then have to deselect that particular file (which is simple; just hold down the CTRL key and left-click on the file and it will leave all the other files selected while the locked file is unselected) and then attempt the process again. If another file is encountered that is locked, wash/rinse/repeat. Are we having fun yet?
Why didn't the big brains at M$ come up with a way to continue without having to go through all of this? How difficult, really, would it have been to put in an option to "ignore file and continue". They provide this option when overwriting files that already exist with files of the same name. Come on M$, pull your head out of your... uh, well, you get the picture.
Ahhhhh... God Bless the command prompt. It once again comes to the rescue. There are a few options when it comes to this process, but let's stick with "xcopy" for now. This is, in my opinion, the best and easiest way to go. I will only point out the basics here. If you want to get into some of the more involved options, type "xopy /?" from the command prompt and it will spit out all of the switches you can use.
Once again, open the command prompt by clicking "Start > Run" and typing "cmd" in the "Open" field, then clicking "OK". Now, let's say we have plugged in our external drive and we want to copy everything from the system hard drive. We will assume there is only one partition and one drive. If a system has more than one drive or partition, simply repeat the process for the appropriate drive/partition. As this example assumes a single drive with one partition, our external drive will most likely be assigned a drive letter of "E:\". If you open up "My Computer" and look at the drive letters, the new external drive will typically have a "type" of external. You may have to format the drive, which can be done by right-clicking on it and selecting the "Format" option. Leave the defaults, except for maybe the volume label. This is just a text label to help describe the drive.
It is my personal preference to create a new directory on the external drive that describes where the data came from. This is even more important when the system drive has multiple drives or partitions. I would use a descriptor like:
\OldSystem_Cdrive
We can create the new directory in Windows or do it from the command prompt. In order to create it from the command prompt, change first to the external drive by typing in "E:" and pressing Enter. Make sure the cursor is blinking next to "E:\>", type in the following command, and press Enter:
md OldSystem_Cdrive
As I discussed in my last post, case will not make a difference here. Windows will "display" the case you specify, but it is not necessary to use the same case every time you type the folder name.
Now, change to the newly created directory by typing the following and pressing Enter:
cd OldSystem_Cdrive
And for our final trick, we will now use xcopy to suck everything from the computers C:\ drive into our new folder (ok, so it really isn't sucking as much as it is mirroring, but I happen to like the word "suck", so like it or lump it). Type in the following command and press Enter:
xcopy c:\*.* /s /e /v /c
The magic in this one is the /c option. This tells xcopy to continue even if an error occurs. This just seems to be beyond the Windows user interface. Ok, now my bitching has turned to whining. I'll stop. Needless to say, this means the process will not only possibly, but likely skip some files. The good news is, the files it will skip are going to be operating system files that you really wouldn't need anyway. As long as you do not have any other applications open whilst running the xcopy, it is extremely unlikely that anything that might be important to you will be skipped (about one one-hundredth of one percent of a chance... but that's just a pull-it-out-of-my-ass guess - seriously, though, the chances are really too small to calculate).
Anyhow, the /s option is the now familiar "this directory and all sub-directories", the /e option (which is a little redundant, but I prefer to include it anyway) says to include even the empty directories and sub-directories, and the /v option says to verify the file after it is copied. The last one simply takes a look at the original, then looks at the new copy, and makes sure they are exactly the same.
That's all for today. There is much more about the command prompt that I intend to discuss, but I will move into some areas that more resembles real Windows topics next time around. My plan is to provide a few tips and tricks to help make things run a little faster.
p.s. Please do not look for posts here every day. It just worked out that way this time, but I doubt I will be able to be that fanatical about it. Also, I know I promised pretty pictures this time, but I did not have my portable drive near me to take said pictures with. I will try to get this post edited in a day or two and add those in.
I hope your day is filled with sunshine and grace!
Friday, February 1, 2008
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!
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!
Subscribe to:
Posts (Atom)
About Me
- kyle.e
- 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?