Here I will explain how to create and delete files or directories in Matlab. This can be used to copy or move files as well. In fact, Matlab can issue any system command. I will show how to do it on Linux platform since its what I use everyday. Basically, we can use a default Matlab function that is called system. It executes a command just like if you were typing it in the terminal.
To create a directory:
Now lets try to save the output of the system command in Matlab. Lets try to list whats inside the current directory using ls command.
Now lets look at the output:
status = 0 result = my_new_directory_name
The current directory now contains my_new_directory_name as expected!
Now lets move into this directory
You can programatically issue commands:
i=1 folder_name=['folder',num2str(i)] command=['mkdir ',folder_name] system(command)
We have just created the folder “folder1” !