Prolemn with close Matlab folder
5 views (last 30 days)
Show older comments
Hi everyone,
I have a problemn like the picture. When I use Matlab program, I try to rename the folder containing *.mat files. Although, all files had closed, I can not rename it. Can you help me? Thanks a lot!
Thu Nguyen
![folder_problemn.PNG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/246526/folder_problemn.png)
3 Comments
Walter Roberson
on 5 Nov 2019
You cannot typically cannot rename a folder that is your current directory.
Accepted Answer
galaxy
on 6 Nov 2019
Edited: galaxy
on 6 Nov 2019
You need to check movefile function which you used is OK or NG
- Original, after cd command.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/246926/image.png)
2. after use movefile
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/246927/image.png)
3. after use rmdir
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/246928/image.png)
Because you jump to testpatient folder, so you can use rmdir('Opt_data') only.
If you still problem, if you can, please send me the source code, I want to see it
11 Comments
galaxy
on 6 Nov 2019
Edited: galaxy
on 6 Nov 2019
Currently, I am working in Japan.
When you change to 2015a, only 1 problem will occur. From 2013b, matlab did not support matlabpool function. So you need to comment (line 49 - 51 of start_optimization.m) or change as you want.
=> I commented, and your script ran perfectly.
More Answers (5)
thu nguyen
on 5 Nov 2019
2 Comments
galaxy
on 5 Nov 2019
In Matlab, you can modify any folder's name if this folder is contained in Matlab path.
In this case, maybe you rename after you used files or addpath to this folder. So you can not.
You can check Matlab path by
>> path
Besides, nice to meet you. I am Vietnamese too.
It you have any problems about Matlab, you can ask me
Image Analyst
on 5 Nov 2019
Did you have Windows File Explorer open viewing that folder? That might prevent renaming.
thu nguyen
on 5 Nov 2019
1 Comment
galaxy
on 5 Nov 2019
I can’t believe that happened.
Please close all application, folder in your machine and tell me procedure you use MATLAB.
ex:
- open MATLAB
![3.PNG](https://www.mathworks.com/matlabcentral/answers/uploaded_files/246553/image.png)
- rename of New Folder to xxx
- error occur
thu nguyen
on 5 Nov 2019
4 Comments
Walter Roberson
on 6 Nov 2019
Whenever you add functions to the top of the path, they take priority over any built-in functions by the same name. That can lead to problems for a variety of programs, not just when you are using that particular software. If you add to the bottom of the path, then any function names that are duplicated would only be a problem running that particular software.
thu nguyen
on 5 Nov 2019
7 Comments
galaxy
on 6 Nov 2019
You received this error because folder not empty.
You need to use rmdir after you use movefile, when Opt_data was empty,
thu nguyen
on 6 Nov 2019
2 Comments
galaxy
on 6 Nov 2019
You use movefile wrong.
You move Opt_data folder to in Opt_data_0 folder.
You need move all files in Opt_data folder only.
You can use as below
cd ('D:\Thu_30-8-2015\Phd\Matlab_program\code-checked\code_demo\Patients\testpatient');
movefile('Opt_data\*','Opt_data_0');
rmdir('Opt_data');
See Also
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!