Posts tagged Webmaster Tutorials

All you ever wanted to know about DOS: Copy

0

In this tutorial, we're going to talk about more essential commands to know in DOS. We're going to get a little more loose with the syntax in this tutorial so knowledge of the bare essentials is key in fully understanding this new loose syntax.

Revised Syntax

In previous tutorials, we've typed the path to files long hand. For example:

C:\Users\Dennis> cd C:\users\dennis\documents\downloads

Note: For the differences between the three filing systems, please click here.

This is meant to under stand the syntax of the path and used to learn how the files are structured in XP, Vista, and Windows 7. The short hand version assumes that knowledge of the "file tree" is known and understood easily. The short-hand notation saves time and makes navigating through DOS more efficient. Short-hand notation is like the following:


C:\Users\Dennis> cd music
vs.
C:\Users\Dennis> cd C:\users\dennis\music

Both of these examples will take us to the same destination. The only difference is that the latter example provides the entire path to the destination (which is somewhat redundant) and the first example already assumes we're talking about a Music directory that exists in the path C:\users\dennis.

Copy

Being graced with this "revised syntax" we can now commence and learn more commands in DOS! Our first command is an extremely useful command: copy. The most widely used command once upon a time but has been eclipsed by xcopy which has been succeeded by robocopy (Vista and 7 only).

The copy command is slightly more complex then any other command that we've gone over so far. There are more switches that can be used to dictate how the command executes and we need to write two paths. The syntax is as follows:


C:\> Copy [switches] source [switches] [drive]

path] destination [switches] [drive]

!path]

C:\> Copy *.* d:
C:\Users\Dennis\test copy stuff.txt C:\users\dennis\desktop

The first command will copy all files in the current directory to the D: drive. This is an unsophisticated way of creating backups of files and folders.

The second example is copying the file from the directory C:\users\dennis\test to C:\users\dennis\desktop.

Useful Switches

The copy command comes with useful switches that all us to define what type of file we are copying and what actions we want to take once the file is copied.

Switches Description
Source Switches There are two separate switches for source and destination
/A Indicates that the file is an ASCII Text File
/B Indicated that the file is a Binary File
Destination Destination Switches
/V Verifies that the copy was successful and done correctly.
/N Uses a short filename, if available, when copying a non-8-dot 3 name.
/Y Suppresses prompting to confirm that you want to overwrite an existing destination file.
/-Y Causes prompting to confirm that you want to overwrite an existing destination file. The prefix (-) means "not" in most cases.

Cool Copy Tricks

There are two cool tricks that stand out with the copy command. The first:


C:\> copy con stuff.txt
This is some text^Z
1 file(s) copied.

The copy command when combined with con allows us to create a text file that we want to copy to the directory. the ^Z is done by pressing control+z, this saves and exits. Though, an easier way is to use the edit command.

The second trick is equally as cool and makes sense if you know xcopy or robocopy (Vista and 7 only). This trick will actually allow us to combine the contents of two files together. For example:

C:\users\dennis\test> copy stuff.txt+more-stuff.txt

This will copy the contents of more-stuff.txt and combine it with stuff.txt We can verify that the copy was successful by using the type command to view the contents of the .txt file.

Basic Unix Commands - Part 1

0

Similar to using DOS in windows, in Linux and Mac OS X operating systems, you can use the terminal using Unix Commands. Here I will just quickly highlight the basics of how to use unix commands.

Once you open the terminal, you can start typing commands. After typing a command hit the enter key to execute it. When a command is finished executing it will display another prompt where it will wait for another command. Some commands will output things into the terminal window and others won't.

Navigating the File System

Using unix commands, you can navigate through all your files and folders using just text. When you open a terminal window you start in your user account's home directory. If you type the command ls you will see all files and folders within your home directory listed.

Unix commands also have options that you can set on them. For example the command ls -l would also list all your files but include more information like size and date.

Changing your current directory

To change your current direction you use the command cd [directory]where [directory] is the path to the directory you want to move to. For example if my current directory contains a folder called "Documents" and I want to move into this folder I would type cd Documents.

The command cd .. would move me to the parent directory of the current directory and cd ../../ would move me to the parent of the parent directory. A command like cd Documents/files would move me into the files directory that is inside the Documents directory. And you can use all different combinations of these like cd ../Music/songs would move up one directory and then into the Music/songs directory. If you try to move to a directory that doesn't exist you will get a message output that says "No such file or directory".

Deleting files and folders

To delete files in Unix you use the command rm [file] where [file] is the name of the file you want to delete.

To delete an entire directory and all the files contained in it, you use rm -r [directory] where [directory] is the path the directory you want to delete. Be very careful with this command as you could accidentally delete a lot of files all with the one command.

XP versus Vista and 7

0

The title is somewhat misleading. We're not going to go over the ins and outs of XP, Vista, and 7, we're not going to be comparing their kernels, hardware, structure of the OS, etc... This is simply on the drastic differences between the XP file system and the Vista/7 file system. Any user that switches from one OS to the other will notice that their files are stored differently.

XP

XP was somewhat revolutionary back in the day because it was a stable OS based on Windows NT, it was unlike any other Windows OS at the time, the themes were great, the graphics were state of the art, and the list goes on and on.

One advantage XP had over previous Windows Operating Systems was the file structure, how data was stored in the folders on the hard drive. This new file structure was an easy way to navigate through the hard drive to quickly find exactly the file you need. The file tree was easy to remember and it looked like the following:

XP

This diagram does require some explanation, however. Admin, All Users, and Username (this is your account) do not all share "My Documents". They are actually three difference types that they share. Think of this as it's own user so no files are shared with the others.

Admin

  • Admin Documents
  • Admin Startup
  • Admin Favorites
  • Admin Desktop
All Users (Shared Documents and Programs)

  • Shared Documents
  • Shared Favorites
  • Shared Startup
  • Shared Desktop
Your Username

  • Your Documents
  • Your Favorites
  • Your Startup
  • Your Desktop

Each user has their own documents, favorites, etc... All Users will grab anything that is shared including programs, documents, startup programs such as anti-virus, and shared desktop items like shortcuts, etc.

Vista and Windows 7

Vista and Windows 7 have a different file structure than XP and is even easier to find files and folders in my opinion. One big advantage is the cut of "documents and settings" and it being replaced by "users". Here is the general vista and 7 file structures:

Note: Vista does not contain the prefix "my" in front of any folders. They are simply "Documents", "Pictures", "Music", etc.

Windows 7

From this chart, we can see that the path to files is significantly neater than XP. There are fewer directories to deal with, less typing involved in the command prompt environment, key directories like music and pictures are not embedded in my documents folder anymore, and many more advantages.

As mentioned for the XP file structure above, Your Account and Public will not contain the same files and same directory names. They are two different users; however, Vista and Windows 7 illustrate this concept much more clearly then XP does.

All you ever wanted to know about DOS: Copying, Renaming, Type, and Edit

1

Today we're going to talk about Copying, Renaming, Creating Text Files, and displaying what is inside files when using DOS. These tutorials assume that a general knowledge of DOS is already known. The first tutorial and second tutorial are excellent resources when learning DOS.

Diskcopy

Diskcopy is a command that allows us to copy the contents from one floppy disk to another. This can be useful to create backups of the contents on a floppy disk. This can be useful in easily backing up content on a floppy that contains old finical records and other important documents from the golden days of 3.5" floppy disks.

C:\> diskcopy a:
This would make a copy of the disk that is currently in the a: (default floppy) drive. You should not use diskcopy for anything other than floppy drives, however.

dos

Rename or Ren

Rename or Ren allows us to rename files and folders. Let us start by navigating to our directory that we want to test our files in. The default directory for vista and XP will suffice for this example.


Vista/7
C:\Users\Dennis>mkdir test

XP
C:\Documents and Settings\Dennis>mkdir test

The mkdir command creates a new directory in the current directory that we're in so no need to put the entire path to the new directory.

The syntax for the ren/rename is a little strange and nothing like any command previously mention before in this series. Be sure the path points to the parent directory (one level above the test directory), otherwise an error will occur. The syntax is the following:


ren [drive]

path]

!current name] [new name]

Example:
ren C:\users\dennis\test test2

dos

To verify the name change actually occurred, use the dir command to view the contents of the directory.

Edit

The edit command is a very basic text editor in DOS. This allows us to type basic .txt files without word wrap, without spell checker, without any configuration whatsoever.

There are two flavors of the edit command. There is the default blue background\white text option and then we can add a switch that makes the window and text the same as the default DOS window (black background and a light-gray text).

edit edit

In order to activate the edit window, all we need to do is simply type "edit".

C:\users\dennis\test> edit

Type a few lines of text and then press file and save as.

edit edit

Once the file is saved (be sure to include the file extension ".txt"), double check to make sure the file was successfully created by using the dir command.

Type

The type command allows us to view any files created using the edit command regardless of file extension. Files encoded with Microsoft Office such as .doc or .docx cannot be viewed using the type command. The syntax of the type command is as follows:


[Drive:]$$!path]\type [filename.file extension]
C:\users\dennis\test>type dosstuff.txt

type

Notice that we are able to view any file extension as long as it was encoded using the edit command in DOS. If we were to view a file encoded in Microsoft Office 2007 it would look like the following:

type

Notice the arbitrary characters that occur when we try to view documents encoded using MS Word. This is because the encoding format is something that DOS cannot read.

All you ever wanted to know about DOS: Making & Deleting Files and Folders

0

In this tutorial we will be talking about the creation of directories, removal of directories, and deleting files within DOS. When juxtaposed with navigation, this can be a powerful ally when removing viruses, recovering data on a bad hard drive, deleting stubborn files, and accomplishing simple tasks easily and effectively.

Disclaimer: I am not responsible for any mistakes you make while using DOS. These tutorials are merely for information purposes only.

Why?

Often, we might hear the question, "why would you wast time doing this in dos when you can just right-click and make a new folder or hit delete on a keyboard?" DOS is a useful tool to know especially if we're dealing with data recovery in safe mode, virus removal in safe mode, fixing a problem, or using certain 3rd party utilities like Disk Wipe.

Making Directories

Making directories is a useful tool when weeding out good files from bad, old from new, and organizing files in something like safe mode.

For those that are familiar with unix commands, this will be like an old friend. The command for creating a new directory is md or mkdir, both do the same exact thing in DOS.

Although we need not navigate to the directory in which we wish to put our new directory in, we can do so by using the chdir or cd command as seen in the first tutorial. Navigating to the parent directory where we will create a child directory is usually a good idea so we can easily see if the directory was created successfully.

Choose a Directory


C:\> cd C:\users\dennis\music
C:\> cd C:\documents and settings\dennis\my documents\my music

The above line is Vista/7 and the below line is XP.

dos

Once we have chosen, we can create our directory in our music folder like the following:

Create the Directory


mkdir C:\users\dennis\music\test
md C:\documents and settings\dennis\my documents\my music\test

Remember that mkdir and md are both legal when using the command prompt.

This will create the directory called "test" in the drive C:\ with a path to users > music and then it will create the directory.

dos

One common mistake that happens is that some consider the md as a single command and then you type in the name of the directory we want to create. Allow me to demonstrate:


mkdir C:\ test //This is wrong
mkdir C:\test //This is right

The first example has a space between C:\ and "test" and therefore renders the command invalid. If we take a look at a website URL, we'll see that it is almost identical.

http://www.atomicpages.net/images/stripes.png is pointing to the world wide web address called atomicpages with the TLD of .net to the directory called "images" which contains a file named "stripes.png".

Ironically, the only difference between a URL and DOS is the type of slash that it uses. A website URL uses a forward slash (/) and DOS uses a backslash ($$.

Applying this logic when creating a directory, we can see that it would make sense to merely continue until we reach the directory that will be created.

Deleting Files

Deleting files in DOS is somewhat of a godsend. At times, there are files that you cannot delete regularly using the Windows GUI so we have to resort to DOS to do our bidding for us. This also can be extremely useful when combating a virus in safe mode.

Deletion of files comes in two flavors:

Del Erase
Originally, the DEL command could not have any wildcards in the parameter of the command. So del C:\ *.* /f would not work. ERASE, on the other hand, was specifically created to allow wildcards and also to erase the files.

Do NOT try del C:\ *.* /f or erase C:\ *.* /f unless you want your entire C: drive wiped clean.

There are times when either command is appropriate, however. If a directory or file is being stubborn and the del command is not working, try the erase command instead.

Useful Switches
/p /q /f /a
This prompts before deleting of files. This can be useful if you have to delete a small number of files but don't want a certain file deleted. Enables "quiet mode" where you are not notified to confirm deletion of any files. Useful for a large number of files. Enables a forceful deletion of files Activates attributes that can help you define which files you want to delete. Use del /? for more details.

To further illustrate the minor difference between del and erase, there once was a time where I had a Windows.old file from a clean install from Vista to 7. For the life of me I could not remove this directory. I tried viewing hidden files and folders, tried using del C:\windows.old /f tried rd C:\windows.old and then I tried the following: erase C:\windows.old /f and then finally I was able to remove the directory.

Using Del and Erase

A good way to practice is to go to lipsum.com and generate however many words, paragraphs, or bytes of words you want to create new .txt documents by right-clicking and selecting new from the menu in Windows. Name them different things and then navigate to our test directory and display the files within the directory via dir.

If we want to delete all of the folders, we would type the following:


C:\> del C:\users\dennis\music\test
C:\> del C:\documents and settings\dennis\my documents\my music\test

C:\> del C:\users\dennis\music\test\*
C:\> del C:\documents and settings\dennis\my documents\my music\test\*
Are you sure (Y/N)?

dos

Notice how DOS automatically puts \* at the end so that all files will be deleted. Erase will work and look the same as del in this situation.

Removing Directories

Removing Directories through DOS will save you heartache in the long run especially if the directory is one you could not delete normally through the Windows GUI.

rd or rmdir is the command we would use to remove a directory. If the directory is not empty we'll get an error like the following:

dos

Be sure the directory is empty using the erase command and then do the following:


C:\users\dennis\music\test\> ..\ \\brings you up one dir
C:\users\dennis\music\> rd C:\users\dennis\music\test

C:\> del C:\documents and settings\dennis\my documents\my music\test\> ..\ \\brings you up one dir
C:\> del C:\documents and settings\dennis\my documents\my music\>
rd C:\> del C:\documents and settings\dennis\my documents\my music\test

dos

The ..\ literally brings us up one parent directory or up one level in the file tree.

That's it! Now you know how to use basic commands that allow you to create folders, delete files, and to remove folders from your hard drive.

Go to Top