Make new folder - MATLAB mkdir - MathWorks Deutschland (2025)

Make new folder

collapse all in page

Syntax

mkdir folderName

mkdir parentFolder folderName

status = mkdir(___)

[status,msg]= mkdir(___)

[status,msg,msgID]= mkdir(___)

Description

example

mkdir folderName createsthe folder folderName. If folderName exists, MATLAB® issuesa warning. If the operation is not successful, mkdir throwsan error to the Command Window.

example

mkdir parentFolder folderName creates folderName in parentFolder. If parentFolder does not exist, MATLAB attempts to create it.

example

status = mkdir(___) creates the specified folder and returns a status of 1 if the operation is successful or if the folder exists. Otherwise, mkdir returns 0 and does not throw a warning or error to the Command Window. You can use this syntax with any of the input argument combinations in the previous syntaxes.

example

[status,msg]= mkdir(___) also returns the message text for any warning or error that occurs.

example

[status,msg,msgID]= mkdir(___) additionally returns the message ID for any warning or error that occurs.

Examples

collapse all

Create Subfolder in Current Folder

Create a folder called newdir in the current folder.

 mkdir newdir

Create Subfolder in Specified Parent Folder

Open Live Script

Create a folder called newfolder in the folder testdata. Use a relative path, where newFolder is at the same level as the current folder.

mkdir ../testdata newFolder

Create Folder That Already Exists

Open Live Script

Create the same folder twice, verifying the status of the operation after each try.

Create the folder newFolder. The operation succeeds, returning a status of 1 with no error or warning message.

[status, msg, msgID] = mkdir('newFolder')
status = logical 1
msg = 0x0 empty char arraymsgID = 0x0 empty char array

Create the folder newFolder again. The operation succeeds again, returning a status of 1. A warning message and message ID inform you that the folder already exists.

[status, msg, msgID] = mkdir('newFolder')
status = logical 1
msg = 'Directory already exists.'
msgID = 'MATLAB:MKDIR:DirectoryExists'

Input Arguments

collapse all

folderNameFolder name
character vector | string scalar

Folder name, specified as a character vector or string scalar. You can specify folderName as an absolute or relative path, unless a parent folder is specified. If you specify a parent folder, then folderName must be a path relative to the parent folder.

If folderName contains a path that includes one or more nonexistent folders, MATLAB attempts to create the nonexistent folder. For example, for the path myFolder\folder1\folder2\targetFolder, if folder1 does not exist, MATLAB creates folder1, creates folder2 within folder1, and creates targetFolder within folder2.

Data Types: char | string

parentFolderParent folder
character vector | string scalar

Parent folder for the new folder, specified as a character vector or string scalar. Specify parentFolder as an absolute or relative path. If parentFolder does not exist, MATLAB attempts to create it.

Data Types: char | string

Output Arguments

collapse all

status — Folder creation status
0 | 1

Folder creation status indicating whether the attempt to create the folder is successful, returned as 0 or 1. If the attempt to create the folder is successful or the folder already exists, then the value of status is 1. Otherwise, the value is 0.

Data Types: logical

msg — Error message
character vector

Error message, returned as a character vector. If an error or warning occurs, msg contains the message text of the error or warning. Otherwise, msg is empty, ''.

msgID — Error message identifier
character vector

Error message identifier, returned as a character vector. If an error or warning occurs, msgID contains the message identifier of the error or warning. Otherwise, msgID is empty, ''.

Tips

  • You can use mkdir to create folders in remote locations. To write to a remote location, folderName or parentName must contain the full path of the file specified as a uniform resource locator (URL) of the form:

    schema_name://path_to_file/folderName

    or

    schema_name://path_to_file/parentName

    It is also valid to use one or three "slash" (/) characters between schema_name and path_to_file. For example:

    schema_name:/path_to_file/folderName

    or

    schema_name:///path_to_file/parentName

    Based on your remote location, schema_name can be one of the values in this table.

    File Systemschema_name
    Amazon S3™s3
    Windows Azure® Blob Storagewasb, wasbs
    HDFS™hdfs

    If the file system being used does not support empty folders then attempting to use mkdir with that service will throw an error. For more information, see Work with Remote Data.

Extended Capabilities

Version History

Introduced before R2006a

expand all

This function supports thread-based environments.

See Also

cd | copyfile | dir | movefile | rmdir

Topics

  • Manage Files and Folders

MATLAB-Befehl

Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:

 

Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.

Make new folder - MATLAB mkdir- MathWorks Deutschland (1)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本 (日本語)
  • 한국 (한국어)

Contact your local office

Make new folder - MATLAB mkdir
- MathWorks Deutschland (2025)

FAQs

How to create a new folder in MATLAB? ›

If you have MATLAB Connector installed on your system, you also can access files and folders in MATLAB® Drive™ from MATLAB. In the Current Folder browser, right-click in white space, and then select New > Folder.

How do you create a folder if it doesnt exist in MATLAB? ›

If parentFolder does not exist, MATLAB attempts to create it. status = mkdir(___) creates the specified folder and returns a status of 1 if the operation is successful or if the folder exists. Otherwise, mkdir returns 0 and does not throw a warning or error to the Command Window.

How to add folder path in MATLAB? ›

Add Folder to Search Path and Disable Folder Change Notification. Create the folder matlab/myfiles . Then, add it to the top of the search path, disable folder change notification, and return the search path before adding the folder. mkdir('matlab/myfiles') oldpath = addpath('matlab/myfiles','-frozen');

How to add all folders in current directory to path MATLAB? ›

Use genpath with addpath to add all subfolders of folderName . MATLAB resolves all path names containing ' . ', ' .. ', and symbolic links to their target location before adding them to the path. This ensures that each entry in the MATLAB path represents a unique folder location.

How do I add a folder to MATLAB drive? ›

If you do not have MATLAB Connector installed, you can add folders and files to your MATLAB Drive using MATLAB Drive online with the Upload button (select Files or Folder) or by dragging and dropping folders and files from the operating system file browser. For either method, empty folders are not uploaded.

How do I create a current directory in MATLAB? ›

To open the Current Folder browser if it is not currently visible, on the Home tab, in the Environment section, click Layout. Then, in the Show section, select Current Folder. In MATLAB Online™, the Current Folder browser is called the Files panel. To show or hide the Files panel, click its icon in the sidebar.

What is the mkdir command? ›

The mkdir command in Linux/Unix is a command-line utility that allows users to create new directories. mkdir stands for "make directory." With mkdir , you can also set permissions, create multiple directories at once, and much more.

Is folder exist in MATLAB? ›

To check the existence of a file or folder, you also can use the isfolder or isfile functions. exist searches for files and folders on the search path, which can lead to unexpected results.

How to set working folder in MATLAB? ›

You can set the initial working folder in MATLAB through the following Preference settings:
  1. Open the Preferences window.
  2. Navigate to the General options.
  3. Select the option to specify a path to a folder under the Initial working folder options, and enter the desired directory.
  4. Press Apply and/or OK to save your changes.
Jul 27, 2017

How do I add a folder to a MATLAB project? ›

You can add or remove folders from the project path. Add project folders to ensure dependency analysis detects project files. On the Project tab, in the Environment section, click Project Path: To add a folder (without subfolders) to the project path, click Add Folder.

How do I permanently add a folder to MATLAB path? ›

Direct link to this answer
  1. Go to "File->Set Path" from within MATLAB or type "pathtool" at the MATLAB prompt.
  2. Use the "Add" button to add your desired folder(s) to the MATLAB path.
  3. Click "Save" so that this path is used in future MATLAB sessions.
Jun 26, 2009

How to get directory in MATLAB? ›

Display Folders in MATLAB Root Folder

Pass the command form of the matlabroot function to uigetdir to display folders in the MATLAB root folder. uigetdir(matlabroot,'MATLAB Root Folder');

How do I add a folder to $PATH? ›

Direct link to this answer
  1. Right-click on the Start Button.
  2. Select “System” from the context menu.
  3. Click “Advanced system settings”
  4. Go to the “Advanced” tab.
  5. Click “Environment Variables…”
  6. Click variable called “Path” and click “Edit…”
  7. Click “New”
  8. Enter the path to the folder containing the binary you want on your PATH.

How do I permanently add a folder to my path? ›

Solution
  1. Right-click My Computer (either on the Desktop or the Start menu). ...
  2. In the System Properties dialog box, click the Advanced tab.
  3. Click Environment Variables.
  4. In the top list, scroll down to the PATH variable, select it, and click Edit. ...
  5. In the Variable Value box, scroll to the end of the variable.
Oct 8, 2023

How do I change the Current Folder to a build folder in MATLAB? ›

Change, and then Restore Current Folder

Change the current folder to C:\Program Files , saving the folder path before changing it. Use the cd command to display the new current folder. Change the current folder back to the original folder, using the stored path. Use the cd command to display the new current folder.

How do I create a shortcut to a folder in MATLAB? ›

In the Files view, right-click the file and select Create Shortcut. Alternatively, on the Project Shortcuts tab, click New Shortcut and browse to select a file. The Create New Shortcut dialog box opens. Select an icon and enter a name.

How do you create a new section in MATLAB? ›

To create a section, go to the Editor or Live Editor tab and in the Section section, click the Section Break button. You also can enter two percent signs ( %% ) at the start of the line where you want to begin the new section.

How do I save in a new folder? ›

With your document open, click File > Save As. Under Save As, select where you want to create your new folder.

How do I create a new workspace in MATLAB? ›

To create a new workspace variable from an existing variable, in the Variables editor, select an element, data range, row, or column in an array, and then in the Variable tab, select New from Selection.

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Msgr. Refugio Daniel

Last Updated:

Views: 5752

Rating: 4.3 / 5 (54 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Msgr. Refugio Daniel

Birthday: 1999-09-15

Address: 8416 Beatty Center, Derekfort, VA 72092-0500

Phone: +6838967160603

Job: Mining Executive

Hobby: Woodworking, Knitting, Fishing, Coffee roasting, Kayaking, Horseback riding, Kite flying

Introduction: My name is Msgr. Refugio Daniel, I am a fine, precious, encouraging, calm, glamorous, vivacious, friendly person who loves writing and wants to share my knowledge and understanding with you.