Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Can someone please tell me how to do this? I can't find any simple tutorials on the internet. I just want a straightforward script that creates folders on my desktop. I'm very tired at the moment, sorry if this post is a mess.

share|improve this question
    
create folder with what name? –  MAKZ Feb 15 at 4:58

4 Answers 4

There is an environment variable named: "USERPROFILE"

This variable holds the path of your "home" directory under the "Users" folder on the drive where Windows is installed.

If you open a command prompt window, and type: echo "%USERPROFILE%", you will see something like:

C:\>echo "%USERPROFILE%"
"C:\Users\your-user-name"

This will also be available as: %HOMEDRIVE%%HOMEPATH% where:

HOMEDRIVE=C:
HOMEPATH=\Users\your-user-name

This folder is the Parent folder for your "Desktop" folder. So, if you wanted to create a folder named "MyNewFolder", on your Desktop from a command window or a batch script, the command would look like this:

C:\>md "%USERPROFILE%\Desktop\MyNewFolder"

These variables (USERPROFILE, HOMEDRIVE, HOMEPATH) are available on Windows 7 (and probably also Windows Vista and Windows 8). For Windows XP and Windows 98, this would have been found under the C:\Documents and Settings folder.

share|improve this answer
    
+1 for detailed explanation, but i think the asker won't understand it –  MAKZ Feb 15 at 4:50

Some operating systems can't find the path when using %userprofile% with cd, but this one seems to work on all Windows versions.

@echo off
: start
cd "%systemdrive%/documents and settings/%username%/desktop"
set /p x= name of folder :
md %x%
cls && goto start

Save the .bat file anywhere, and run it.

share|improve this answer

Here's how I would do it:

  1. Install Cygwin
  2. Open up Notepad
  3. In the blank document, type:

    #!/bin/bash
    mkdir C:\path\to\dersired\directory
    
  4. Hit Ctrl+S
  5. For filetype, choose All files
  6. Save it
  7. Open a command prompt
  8. Type in: C:\cygwin\bin\bash C:\path\to\script\script.sh

You can put other stuff in the bash script too.

share|improve this answer
4  
maybe installing Cygwin isn't the simplest solution to this question. –  stib Feb 15 at 6:05
    
@stib That's probably true, but I feel like having Cygwin installed would have tremendous value in the future as well. –  evamvid Feb 15 at 6:07
1  
So would wiping the Windows partition and installing Linux, or learning Lisp so you could write a program to do it. But not a simple solution to the problem. –  stib Feb 15 at 6:10
    
True! I totally agree =) –  evamvid Feb 16 at 6:01

Write this code in a text file, rename it to [someFilename].bat, and save the file on the desktop:

@echo off
set /p x= 
mkdir %x%

Double-click it, and you will be prompted for input. Enter the desired folder name, and then press enter on the keyboard.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.