This is an article discussion thread for discussing the SitePoint article, “Kev’s Command Prompt Cheat Sheet”
They say the best way to pass a test is to take the test but it sure helps having the answers in front of you! thanks heaps.
i want command promt
Some of those are awesome!
Unless you’re on a Mac.
Ah, a blast from the past! Oh we were great command-line warriors at one time
Want to run a program on every file in a directory?
This passes the file name (minus the extension) of every .xcp file (in the “cwd”) to a program called xc:
@for %%f in (*.xcp) do xc %%~nf
btw… cwd == current working directory
Want to have more control over your directory listing?
This outputs a “bare” listing sorted (“ordered”) by name:
dir /b /on
Want that directory listing sent to a file?
dir /b /on > dir_list.txt
Here’s something you can’t do easily from Windows Explorer.
Let’s say we have a directory of files named like this:
beach001.jpg, beach002.jpg, beach003.jpg, beach004.jpg, etc.
Now we realise those weren’t beach pics at all! We want to replace “beach” with “work” for all those files…
ren beach???.jpg work???.jpg
Pretty cool, eh? But you say some of those pics were gif files and not jpg files? No prob…
ren beach???.* work???.*
Let’s create a network share called “shared_src” on a computer named “main_server”:
net share shared_src=c:\\public\\src
Now on a different computer (on the network) lets map x drive to that share:
net use x: \\\\main_server\\shared_src
Let’s compare two different directory structures and save any differences in a file:
c: cd \\projects\\old dir /on /s > ..\\old.txt cd \\projects\ ew dir /on /s > ..\ ew.txt cd .. fc new.txt old.txt > project_comparison.txt
Ah, those were the days
Disclaimer - It’s been a long time since I used some of these. Note that you can screw things up with some of these commands.
heh this brings back memories…
The Command Prompt (I still call it a “DOS Box” ;)) can be very useful - I use it often. One problem with opening a Command Prompt from the “Start” menu is that, after opening it you then have to “cd” (change directory) to the directory where you need to work. Here’s something I did to help. The following creates a new action for the “Folder” file type. After doing this you can right-click on a folder (in the “Folders” view of Explorer) and select “Command Prompt” and it will open it with the “CWD” (current working directory) set to the folder you right-clicked on.
On the main menu bar of Explorer (not ‘Internet’ Explorer) click “Tools”, then “Folder Options…”, then the “File Types” Tab. Now you see a list of file types. Look for one named “Folder”. There is also one named “File Folder” - don’t select that one, select the one named “Folder” (I have Windows XP Pro so things may be different for you now, depending on what version of Windows you have). Click the “Advanced” button. Now you get a dialog box named “Edit File Type” - it has a list of “Actions” (you’ll probably see the “explore” and “open” actions already there). Click the “New…” button. Now you get a dialog box named “New Action” which has two text fields. For “Action” I used this: Command Prompt. For “Application used to perform action” I used this: C:\WINDOWS\system32\cmd.exe “%1”. Click the “OK” buttons for all dialog boxes you opened.
This has been very useful to me. I hope it is useful to you
damn I DO miss the days of the dos prompt even though I still use it a lot. I think thats why I enjoy the console on my servers so much … and the wonderful thing is? It ONLY does what you tell it to do (unlike some “other” apps we wont mention)
nice article … made me feel “homesick” for the good old days!
I used a command a while back and I cant remember what it was. I was looking up some AIM tricks or something. It allowed you to view who was trying to hack into your machine or who else was on your network. Which a while back when I used it someone on Comcast broadband was trying to connect to my network, while I use bellsouth DSL.
does anyone know what it might be? thx
its great. i want more … plzz give tutorials on how to search for a file in a given folder… and things like tht…
Ya it was probably netstat
simply get into command prompt and type netstat and it will show a list of the connections to your computer with their ips.
Hope this helps
It should be noted that these DOS commands can be stored in batch files for easy use later. A batch file is just a text file with a “.bat” extension.
how can you turn on the net send?? and is there anything i can load up to send messages on command prompt??
you have to go to START>CONTROL PANEL>ADMIN TOOLS>SERVICE
Then you have to look for MESSENGER. Click once on messenger and then right click, and select START.
I tried using thits and I just figured out how to change directories, I think. But it keeps saying access is denied. Before it just had error messages. Am I doing something wrong or do I need to change some settings?
I used this CD “Program Files” command, but i got one error messge that is (Parameter Format Not Correct - "Program)
Please give suggestion
my mail id is email@example.com
i’m having a little problem and i hope that one of you may be able to help me. i cant access my ipconfig command screen.
after opening run, i type ipconfig, just as before, only for the last few days, i get a blink/blinding black screen, like its about to open and then it closes again.
Ipconfig will auto-close (typical with other DOS programs)once completed, to see ipconfig you need to enter the command prompt first, i.e. start -> run -> cmd -> ipconfig
thats a nice tutorial