Showing posts with label Command Prompt. Show all posts
Showing posts with label Command Prompt. Show all posts

Saturday 28 November 2009

By Your Command: File and Folder paths the easy way

When using the Command Prompt you can avoid typing the whole path for files and folders by dragging and dropping them onto the Command Prompt window. This video shows this time-saving feature in action.

Please note that this function does not work with all icons such as the My Documents icon on the desktop.

More Command Prompt tips soon.

Tuesday 22 September 2009

By Your Command: A Rough Guide to the Command Prompt, Part 2

In a previous post I explained how to navigate to different drives and folders using Command Prompt. I also showed how to list the contents of the current folder using the dir command. We will now look a little closer at this command.

In the tutorial, I suggested typing the following command dir /a-d /b > filelist.txt. We shall not worry about the > filelist.txt part for now, but rather look at the anatomy of the dir command itself to serve as an example of how Command Prompt works.

Following the dir command there are two switches: /a-d and /b. These switches alter the way in which the command works. In this case they adjust what folder contents is listed and how it is presented: /a-d stops the dir command from listing folders; /b prevents the command from showing the extra information you see if you just type dir and hit Return.

You can list all the switches associated with dir by entering dir /? in the Command Prompt. The /? switch provides help for any command it follows. In the case of dir it returns something like this:

This may be a little forbidding for the novice; so, I will give another example of switches in action. If you wanted to list all the folders (or directories as they are known in Command Prompt) at the top level of your D:/ drive you would enter -

dir d: /ad
[Note that switches are not case sensitive]

If you wanted to also list all the sub-folders, you would enter -

dir d: /ad /s

You may notice how all the information scrolls past really quickly. To pause after each page of information you can use the /p switch. Thus, the command becomes -

dir d: /ad /s /p

To list all the mp3 files on drive D: pausing after each page use the following command -

dir d:\*.mp3 /s /p

The asterisk is a wildcard. In other words. it means 'any combination of letters'. So if you wanted to list all the mp3 files with the word 'Beatles' in the filename you would use -

dir d:\*beatles*.mp3 /s /p

The dir command is a good way of having a play with the command prompt safe in the knowledge that you will do no harm to your files. If you have any questions about this command feel free to leave a comment and I will do my best to address them. More commands next time.

Wednesday 9 September 2009

By Your Command: A Rough Guide to the Command Prompt, Part 1

Before the rise of graphical user interfaces (GUIs) the main method of controlling computers was through text based operating systems such as MS-DOS. You can still use these old DOS commands using a facility called Command Prompt that is available in all forms of Windows. In this first part of this rough guide, we will look at how to open the Command Prompt and we will explore some of its features.

You can run the Command Prompt from the Start menu. You will find it in the 'Accessories' folder. Alternatively you can open it by typing cmd in the Run box, which you can either open from the Start menu or by holding down the Windows key and pressing R.

In Windows Vista and 7, certain commands are unavailable unless you run the Command Prompt as an administrator. To do so you can right-click on the icon in the Start menu and select 'Run as administrator' from the menu. You can also use the Run box: type in cmd as before and then hold down the Ctrl and Shift keys and press Enter. You may be required to supply an administrator password at that point.

The Command Prompt will look something like this:


Click on the icon to the right of the title bar [circled in red] to open a menu. There are items in this menu to enable you to edit commands and change the look and feel of the Command Prompt. The usual copy and paste keyboard commands do not work in the Command Prompt so you will have to use the edit menu to do so. This menu offers a variety of other features including 'Find'.

To change the appearance of the Command Prompt, you can either click on 'Properties', which will alter the look and feel of the current session and, should you wish, other sessions started the same way, or you can click on 'Defaults' to change the appearance any Command Prompt you open from now on (Note: this does not over-ride changes made using 'Properties'). Either way, a box will open with a different title and a few different options depending on whether you clicked 'Properties' or 'Defaults'.

'Options' tab


On the 'Options' tab you can change the cursor size from a thin flashing line to a flashing box. The 'Command History' settings alter the way that the Command Prompt remembers previous commands, something that we will explore in a later post. The 'Display Options' enable you to set the Command Prompt to appear full screen if you so desire.

In the 'Edit options' you can activate 'Quick edit mode', which lets you use the mouse to select text. 'Insert mode' functions in the same way as the Insert key, allowing you to either insert what you type or overwrite any text to the right of the cursor. On the 'Defaults' options there is an extra setting: 'AutoComplete'. This enables you to use the Tab key to complete folder and file names.


'Font' tab


You can change the size and style of the displayed font here.


'Layout' tab


You can alter the appearance of the Command Prompt window on this tab. The 'Screen buffer size' options affect the width and number of lines, but do not change the visible screen size. Consequently you may have to use the scroll-bars to see all the text. These are particularly useful if you change the font size. The size of the window itself can be changed using the 'Window Size' settings - no surprise there. You can also decide where the Command Prompt appears on the screen using the 'Window position' settings.


'Colors' tab


If you wish to have yellow text appear on a dark blue background, then this is where you can make it happen. You can also set the colour of the Popup text and background. We will look at some of these popups in later posts.

For those of you eager to impress your friends with your 'old school' computing skills, check out a previous post in which I looked at changing the current directory and listing its contents.

Next time I will look at a few simple commands.

Thursday 12 June 2008

Command Window Here: Free MS PowerToy for XP

In the last post I have instructions for using the Command Prompt to navigate to a particular folder; however, there is an easier way to do this in Windows XP by installing a PowerToy (this feature is already available in Vista).

To install this feature, look for 'Open Command Window Here' the list of PowerToys on the right hand side of the page and click on CmdHere.exe to download it (or simply click here - if this links stops working please leave a comment). After installing the software, when you right click on a folder icon, or on the empty space within a folder, you will see a new entry in the menu that opens: 'Open Command Window Here'. Click on this to open up a Command Prompt window that will already be focused on the current folder.

There are a number of other PowerToys available, including the excellent Clear Type Tuner, which was the subject of an earlier post. In future posts on this blog, I will look at some of the other tools available to enhance Windows XP.

Wednesday 4 June 2008

How to save a list of files in a folder

There are a number of programs available that will create a text file from a list of files in a folder, but here is a quick and easy way of doing the same using the Command Prompt.

Firstly, open up the Command Prompt (aka the MS-DOS Box). To do this either click on 'Run' in the 'Start' menu, or hold down the Windows key and press R (the Windows key is the one with the Windows logo on). In the box that opens type cmd, and either click the 'OK' button or press the Return key. The Command Prompt application should open, looking something like this.


Secondly, you will need to navigate to the folder which contains the files you wish to list. If it is on a different drive type the drive letter followed by colon (e.g. D:) and hit return. Then type cd (change directory) followed by the path of the folder, for example:

cd c:\documents and settings\owner\my documents


On some versions of Windows you only need to type part of the folder name and then press the Tab key and the Command Prompt will fill in the rest, e.g. type cd c:\docu and press Tab to change the command to cd c:\documents and settings.

If you do not know the full path of the folder, you can set Windows Explorer to show it in the address bar or title bar - one of my earlier posts explains how to do this (I would recommend showing the full bath in the address bar). You can copy the path from the address bar and paste it into the command prompt screen by clicking on its icon in the top left hand corner, which opens a drop down menu as shown below.


Once you have navigated to the right folder you can type the command to create a file list in that folder in the form of a text file that can be opened in notepad or your word processor.

Note: Windows Vista includes a feature where you can hold down the Shift key and right-click on the icon of the folder you wish to list the files contained within and select 'Open Command Window Here' from the menu that opens. I will be publishing a post soon which will provide instructions on how to add this feature to Windows XP.


Directory List Command

To create a list of all the files in the folder type dir /a-d /b > filelist.txt and press Return/Enter.

The command includes two switches, /a-d and /b. The first of these stops the dir command. from listing folders; the second prevents the command from showing the extra information you see if you just type dir and hit Return. If you wish the text file to have a different name change it from 'filelist' but remember to put '.txt' at the end so that Windows knows that it is a text file.

The dir command has a variety of other switches, the following command will list the names of all the mp3 files in the current folder and all the sub-folders that it contains:
dir *.mp3 /a-d /s /b > mp3filelist.txt

The *.mp3 part tells the command to only list files with that extension, and the /s sets it to list the files in sub-folders too. Note that the files in the sub-folders will be listed prefixed by the folder name, e.g. 'D:\soulseek\placebo - covers\01 Running up That Hill.mp3'.

If you have a particular requirement for a file list leave a comment on this post and I will look into it for you. Also, if anyone is interested in learning more about the various commands and programs available in the Command Prompt please leave a comment.

One last point, you can use > filename.txt to send the results of any command to a text file, which can be very useful if you have to pass information on to a technician.

Now you can impress your friends and co-workers with your 'old skool' techie skills.