As I wrote in a recent post, I rediscovered the need to backup my work regularly. I was fortunate. I didn’t lose anything of substance. That was because I had already learned (Yes,the hard way.
) years and years ago how important it is to do backups. I’d become lax, letting weeks go between full backups. Even my daily work didn’t get backed up much more often that that.
When my computer started acting wonky, though, I got concerned. I backed up everything. Then I ran a restore on my computer, restoring it to what it had been when I first bought it. I got it restored and running and had a wonderfully productive week, working on multiple home and business and personal projects. After almost a week, I downloaded and installed the backup program we use, planning to run it the next day. When I tried to start my computer, though, it would not boot. Fortunately, as I said in that previous post, I was able to salvage the files of these projects I worked on. (All but a couple that I completely forgot. I was able to reproduce the work I did on them, though.)
It was forcibly impressed on me that I really did need to back up daily. I needed to establish a system (routine!) that enabled me to do that. Enter Hubby, the Man with a Plan. My husband had realized the same thing. He already kept all his important files in one set of folders and backed up that one file regularly. He decided it was time to automate that process. He created a command file that, when run, copies that folder to a thumb drive and shuts down the computer. He showed me how to make one and now I’m going to tell you.
These instructions are not difficult, but if you are not computer-literate, they are sure to seem complicated and hard to understand. If you are unsure, you should run them by someone familiar with DOS command codes. Don’t do anything you feel unsure about. If you are feeling adventurous, read on.
A command file is basic computer programming. It must be written at at what is called a DOS prompt. To get to a DOS window, also called a command prompt, go to Start > Accessories > Command Prompt. (If it isn’t there on your computer, I have no idea how to find it.
)
My instructions from this point might seem complicated. Read through them a few times, though, and you should be able to reproduce your own command file.
My husband’s command file looks like this.
xcopy d:\gpg g:\ /Y
shutdown /s /t 30
Mine is a bit more complicated.
xcopy “c:\Documents and Settings\stephanie\My Documents\Current\Writing\” /m /y /e G:\Documents\Writing\
shutdown /s /t 30
The first line is composed of four sections.
- xcopy is the command to copy folders.
- Next is the path to the source folder, the folder you want to copy. (His in on his d drive and titled gpg; Mine is “C:\Documents and Settings\stephanie\My Documents\Writing\Test”)
- The next instruction is the destination folder, where you want the folder copied to. (His is on his g drive; Mine is F:\Documents\Writing\)
- The last instruction, “/Y” tells the computer to overwrite any files with identical names. (A list of the the possible commands and a more specific rendering of what they do will be included in the detailed instruction page.)
There are several different variations you can choose for the xcopy command and the shutdown command. To find them, you would go to the command prompt (Start > Accessories > Command Prompt) and type
help xcopy
This is what will appear.
Copies files and directory trees.
XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
[/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
[/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
[/EXCLUDE:file1[+file2][+file3]…]
source Specifies the file(s) to copy.
destination Specifies the location and/or name of new files.
/A Copies only files with the archive attribute set, doesn’t change the attribute.
/M Copies only files with the archive attribute set, turns off the archive attribute.
/D:m-d-y Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time.
/EXCLUDE:file1[+file2][+file3]…
Specifies a list of files containing strings. Each string should be in a separate line in the files. When any of the strings match any part of the absolute path of the file to be copied, that file will be excluded from being copied. For example, specifying a string like \obj\ or .obj will exclude all files underneath the directory obj or all files with the .obj extension respectively.
/P Prompts you before creating each destination file.
/S Copies directories and subdirectories except empty ones.
/E Copies directories and subdirectories, including empty ones. Same as /S /E. May be used to modify /T.
/V Verifies each new file.
/W Prompts you to press a key before copying.
/C Continues copying even if errors occur.
/I If destination does not exist and copying more than one file, assumes that destination must be a directory.
/Q Does not display file names while copying.
/F Displays full source and destination file names while copying.
/L Displays files that would be copied.
/G Allows the copying of encrypted files to destination that does not support encryption.
/H Copies hidden and system files also.
/R Overwrites read-only files.
/T Creates directory structure, but does not copy files. Does not include empty directories or subdirectories. /T /E includes empty directories and subdirectories.
/U Copies only files that already exist in destination.
/K Copies attributes. Normal Xcopy will reset read-only attributes.
/N Copies using the generated short names.
/O Copies file ownership and ACL information.
/X Copies file audit settings (implies /O).
/Y Suppresses prompting to confirm you want to overwrite an existing destination file.
/-Y Causes prompting to confirm you want to overwrite an existing destination file.
/Z Copies networked files in restartable mode.
The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.
Unless you are very computer-literate, this probably looks like nonsense to you. If it still looks like gibberish after you read how I composed my own command file, it’s probably better if you do not attempt to create your own command file. Take this article to a computer-savvy friend and get them to help you create one. If, after reading my instructions, you understand what to do, try your hand at making your own command file to copy files and shutdown your computer.
To start, open a text editor, such as wordpad or notepad. Save the file as a .txt for now. When you have the file the way you want it, you will change it to a .cmd extension. Until you are ready, though, you don’t want to accidentally run the file instead of opening it to edit it. You will also need a command prompt window open to test your code. (Don’t you feel like a big shot now? Using computer code?
)
My command file looks like this:
xcopy “c:\Documents and Settings\stephanie\My Documents\Writing\” /m /y /s
shutdown /s /t 30
There is a space between xcopy and the path of the file I want to copy. Because the path of the folder I want to copy includes spaces in the names, I must enclose the entire path with double quotes. Navigate to the folder you want to copy. Select and copy the path name in the address bar at the top of the folder window. (If the full path is not in that bar, go to tools > folder options > view and select “show full path in the address bar.”)
The next few commands are a slash mark (/) and a letter, with a space after the letter.
The /m tells the computer to only copy those files with the archive attribute set and resets the archive attribute. (If I didn’t want to reset the archive attribute, I’d use /a). Archive attribute means those files that have been edited. I do this so that only those files I’ve actually changed since the previous backup are copied. This save time since I have a lot of files I want to keep backed up.
The /y suppresses prompting when a file is about to be overwritten. Since my hard drive has the latest version, I want the copy to overwrite anything with the same name on the thumbdrive. By suppressing the prompt, I don’t need to remain at the computer after starting this command.
The /s tells the computer to copy all directories (folders) and supdirectories (more folders) except empty ones. If I wanted to copy the empty ones, I’d use /e. This ensures that if I create a new folder and save documents in it, it will be backed up.
After these commands, I put another space and write the path to the place where I want to save the folders
That is the first line of the command code. Check to see if it works at the DOS prompt/command prompt. If it does, and if you don’t want to shutdown after executing the copy command, you are finished. Save the text file one last time and close the window. Navigate to the file and rename (right click on the file, select rename) it, giving it a .cmd extension. (My husband says you should probably not name it backup as that is another kind of command code and it might confuse the computer. The last thing we want is a confused computer. Right?
) Now all you need do is “open” that command file to run it. It will execute those instructions.
The next line of my command code (shutdown /s /t 30) tells the computer to shutdown. It is comprised of three sections.
- Shutdown is exactly what it sounds like, a command for the computer to enter the shutdown sequence.
- /s is the command to shutdown (as opposed to l for log off, r for restart and other options).
- /t 30 tells the computer to wait 30 seconds before starting the shutdown sequence.
As before, test this command at the DOS prompt/command prompt. If it works, save it in your .txt file. (After restarting the computer, of course, since it will be shutdown if the command worked.
) Rename your text file to a .cmd file.
Create a shortcut to the command file on your desktop (right-click and drag it to the desktop and choose “create shortcut here.” Now every day, when you are ready to shutdown your computer, run this command file. (Make sure your thumbdrive is in place!) You’ll never lose another day’s work!

Related Articles
No user responded in this post
Leave A Reply