- How to create a directory or folder
- Creating a folder in Microsoft Windows
- My Computer or Windows Explorer
- Windows desktop
- Create a new folder using a shortcut key
- Windows command line
- Creating a directory in MS-DOS and the Windows command line
- Related pages
- Create a directory with a batch file
- Creating a directory in Linux, Unix, and their variants
- Creating a folder and directory in Microsoft Windows 3.X
- File Manager
- MS-DOS
- Creating a folder in macOS X
- Desktop folder
- Create a folder in a directory
- Creating a temporary directory in Windows?
- 9 Answers 9
- Making directories in windows batch script
- 1 Answer 1
- How to install and use “make” in Windows?
- 10 Answers 10
- mkdir mkdir
- Синтаксис Syntax
- Параметры Parameters
- Примеры Examples
How to create a directory or folder
There are multiple ways to create or add a folder, subfolder, directory, and subdirectory on a computer. The methods depend on the operating system or where the directory is being created. Select a link below for steps on how to create a directory and folder in each major operating system.
Creating a folder in Microsoft Windows
My Computer or Windows Explorer
- Open My Computer or Windows Explorer.
- Open the drive or folder where you’d like to create the new folder; for example, the C: drive. If you do not want to create a folder in the root directory, browse to the location of your choosing.
- In Windows 10 on the Home tab, click the New folder icon. In Windows 7 and earlier on the file menu bar, select File and then Folder.
In all versions of Windows, you can also right-click with your mouse on a blank portion of the folder, select New and then Folder.
If you’re using Windows 7 or earlier and do not see the file menu bar at the top of Windows Explorer, press the Alt key and it should become visible.
Windows desktop
- Navigate to the Windows desktop.
- Right-click any blank portion of the desktop.
- In the menu that appears (like that shown in the picture), click New and then Folder.
- A new folder appears. Type the name of the folder you want to use and then press Enter .
Create a new folder using a shortcut key
While in Windows Explorer, you can press Ctrl + Shift + N to create a new folder without using the mouse.
Windows command line
See the following MS-DOS and Windows command line user section for information about creating a directory in the Windows command line.
Creating a directory in MS-DOS and the Windows command line
It is more appropriate to use «directory» instead of «folder» when referring to the command line.
To create a directory in MS-DOS or the Windows command line (cmd), use the md or mkdir MS-DOS command. For example, below we are creating a new directory called «hope» in the current directory.
You can also create multiple new directories in the current directory with the md command. In the next example, we are creating three new directories, called «user1,» «user2,» and «user3,» in the current directory.
If you want to create a directory with spaces, you need to surround the directory name with quotes. In the example below, we are creating a directory called «my example directory» in the current directory.
To create a directory in the parent directory, without first moving into that directory, you can use the command below. This example moves back one directory to create the «example» directory.
To create a subdirectory in a different directory without moving it, use a command similar to the example below. This command creates a «test» directory in the hope directory.
Once a directory is created, you can use the cd command to change the directory and move into that directory.
To make a directory in another drive without moving into that drive, use a command similar to the example below. This command creates an «example» directory on the F: drive. The drive letter «f:» can be substituted from any drive letter.
Related pages
Create a directory with a batch file
A batch file is a series of commands that can be entered in the command line. Therefore, you can use any of the examples from the section above in the batch file to create a new folder.
Creating a directory in Linux, Unix, and their variants
It is more appropriate to use «directory» instead of «folder» when in a command line.
You must have the permissions to create a directory outside of your home directory.
To create a directory in Linux, Unix, or any variant, use the mkdir Linux and Unix command. For example, below we are creating a new directory called hope in the current directory.
Once the directory is created, you can use the cd command to change the directory and move into that directory.
If you want to change the permissions of a directory after its been created, use the chmod command.
Creating a folder and directory in Microsoft Windows 3.X
File Manager
- Open File Manager
- Open the folder where you’d like to place the new folder and on the top menu of File Manager, select File and then new folder.
MS-DOS
See the above MS-DOS user section for information about creating a directory in MS-DOS.
Creating a folder in macOS X
Desktop folder
- Navigate to the macOS desktop.
- Right-click (tap two fingers on the mouse) any blank space on the desktop.
- Select New Folder from the drop-down menu that appears.
- Name the folder, and then press Return .
Create a folder in a directory
- Open Finder and navigate to the directory where you’d like to create the folder.
- Click File in the upper-left corner of the screen.
- Select New Folder in the drop-down menu that appears.
- Name the folder, and then press Return .
Users may also press the shortcut key combination Command + Shift + N to create a new folder.
To create a directory in the Terminal command line, see the Linux steps.
Creating a temporary directory in Windows?
What’s the best way to get a temp directory name in Windows? I see that I can use GetTempPath and GetTempFileName to create a temporary file, but is there any equivalent to the Linux / BSD mkdtemp function for creating a temporary directory?
9 Answers 9
No, there is no equivalent to mkdtemp. The best option is to use a combination of GetTempPath and GetRandomFileName.
You would need code similar to this:
57 bits. You can always make two calls to square it – Marty Neal Jul 25 ’13 at 17:05
I hack Path.GetTempFileName() to give me a valid, pseudo-random filepath on disk, then delete the file, and create a directory with the same file path.
This avoids the need for checking if the filepath is available in a while or loop, per Chris’ comment on Scott Dorman’s answer.
If you truly need a cryptographically secure random name, you may want to adapt Scott’s answer to use a while or do loop to keep trying to create a path on disk.
I like to use GetTempPath(), a GUID-creation function like CoCreateGuid(), and CreateDirectory().
A GUID is designed to have a high probability of uniqueness, and it’s also highly improbable that someone would manually create a directory with the same form as a GUID (and if they do then CreateDirectory() will fail indicating its existence.)
@Chris. I too was obsessed with the remote risk that a temporary directory might already exist. The discussions about random and cryptographically strong don’t completely satisfy me either.
My approach builds on the fundamental fact that the O/S must not allow 2 calls to create a file to both succeed. It is a little surprising that .NET designers chose to hide the Win32 API functionality for directories, which makes this much easier, because it does return an error when you attempt to create a directory for the second time. Here is what I use:
You get to decide whether the «cost/risk» of unmanaged p/invoke code is worth it. Most would say it is not, but at least you now have a choice.
Making directories in windows batch script
I have about 2000 jpg files in a folder, and I need to make a folder for each of them with the same name. The jpg doesn’t necessarily have to be in the same folder. I’m new to batch script, but it seemed like a pretty simple operation. This is what I have so far:
When I run it, it says a subdirectory or file already exists. How do I get it to make a directory even though a file with the same name already exists?
Also, it appears to only loop for the last hundred files. How do I get it to run for all
dpi See end of help for for /? . – user6017774 Jul 19 ’16 at 21:01
1 Answer 1
You can try something like that :
Edit on 20/07/2016 @20:25
in the command-line gives help about this syntax (which can be used outside FOR, too, this is just the place where help can be found).
In addition, substitution of FOR variable references has been enhanced. You can now use the following optional syntax:
The modifiers can be combined to get compound results:
In the above examples %I and PATH can be replaced by other valid values. The %
syntax is terminated by a valid FOR variable name. Picking upper case variable names like %I makes it more readable and avoids confusion with the modifiers, which are not case sensitive.
There are different letters you can use like f for «full path name», d for drive letter, p for path, and they can be combined. %
is the beginning for each of those sequences and a number I denotes it works on the parameter %I (where %0 is the complete name of the batch file, just like you assumed).
How to install and use “make” in Windows?
I’m following the instructions of someone whose repository I cloned to my machine. What I want is simple: to be able to use the make command as part of setting up the code environment. But I’m using Windows, and I searched online only to find a make.exe file to download, a make-4.1.tar.gz file to download (I don’t know what to do with it next), and things about downloading MinGW (for GNU; but after installing it I didn’t find any mention of «make»).
I don’t want a GNU compiler or related stuff; I only want to use «make» in Windows. Please tell me what I should do to accomplish that.
Thanks in advance!
10 Answers 10
make is a GNU command so the only way you can get it on Windows is installing a Windows version like the one provided by GNUWin32. Anyway, there are several options for getting that:
The most simple choice is using Chocolatey. First you need to install this package manager. Once installed you simlpy need to install make (you may need to run it in an elevated/admin command prompt) :
Other recommended option is installing a Windows Subsystem for Linux (WSL/WSL2), so you’ll have a Linux distribution of your choice embedded in Windows 10 where you’ll be able to install make , gcc and all the tools you need to build C programs.
For older Windows versions (MS Windows 2000 / XP / 2003 / Vista / 2008 / 7 with msvcrt.dll) you can use GnuWin32.
An outdated alternative was MinGw, but the project seems to be abandoned so it’s better to go for one of the previous choices.
mkdir mkdir
Создает каталог или подкаталог. Creates a directory or subdirectory. Расширения команд, включенные по умолчанию, позволяют использовать одну команду mkdir для создания промежуточных каталогов по указанному пути. Command extensions, which are enabled by default, allow you to use a single mkdir command to create intermediate directories in a specified path.
Эта команда аналогична команде MD. This command is the same as the md command.
Синтаксис Syntax
Параметры Parameters
Параметр Parameter | Описание Description |
---|---|
: : | Указывает диск, на котором нужно создать новый каталог. Specifies the drive on which you want to create the new directory. |
Указывает имя и расположение нового каталога. Specifies the name and location of the new directory. Максимальная длина любого отдельного пути определяется файловой системой. The maximum length of any single path is determined by the file system. Это обязательный параметр. This is a required parameter. | |
/? /? | Отображение справки в командной строке. Displays help at the command prompt. |
Примеры Examples
Чтобы создать каталог с именем Directory1 в текущем каталоге, введите: To create a directory named Directory1 within the current directory, type:
Чтобы создать дерево каталогов таксес\проперти\куррент в корневом каталоге с включенными расширениями команд, введите: To create the directory tree Taxes\Property\Current within the root directory, with command extensions enabled, type:
Чтобы создать дерево каталогов таксес\проперти\куррент в корневом каталоге, как в предыдущем примере, но при отключенных расширениях команд введите следующую последовательность команд: To create the directory tree Taxes\Property\Current within the root directory as in the previous example, but with command extensions disabled, type the following sequence of commands: