Using addpath with file/folder names with / and :

I am using the addpath to link a folder to my path, but the name of the folder includes a /, how do I include characters such as / and : in the file name?

1 件のコメント

José-Luis
José-Luis 2014 年 10 月 3 日
How is that even possible? The slash is a restricted character in filenames.

サインインしてコメントする。

回答 (2 件)

Image Analyst
Image Analyst 2014 年 10 月 4 日

0 投票

What operating system is this? I know for a fact that you cannot have a folder name with a / or \ in it in Windows. If you made it up, then you can combine with fullfile
myDrive = 'D:\';
myFolder = 'data/results\run 1';
fullPath = fullfile(myDrive, myFolder)
but in the above case the folder is actually 3 folder names concatenated. Note Windows does not care about forward or backslash and will work just fine with either one.

4 件のコメント

Claudy
Claudy 2014 年 10 月 4 日
I am using a OSX Mavericks (Mac). I had decided just to change the name of the folder and replaced the "/" with "_". Thanks though. I will try your method to see if it works for Mac.
Image Analyst
Image Analyst 2014 年 10 月 4 日
OK, good. I didn't know folder names in the Mac could have a slash in them. I added "mac" to the tags to people will know.
José-Luis
José-Luis 2014 年 10 月 4 日
I learned something today. I only use Linux and Windows and there the slash is a no-no.
Sorry for my somewhat flippant and mistaken answer.
Image Analyst
Image Analyst 2014 年 10 月 4 日
So, Claudy, Jose-Luis's link says that slash is permitted but colon is prohibited. So then, how are you creating folders with colon in them on your Mac, as you said in your original question?

サインインしてコメントする。

Miles Milner
Miles Milner 2020 年 4 月 9 日

0 投票

Hi I have a similar problem, my file directory has a ' in the name and that character closes the arguement
addpath('C:\Users\Miles' PC\Documents\MSc Medical Physics\BP5901 MSc Project\Dicom data')
what do I do? you can see in Miles' it stops being pink...
Please help!!

3 件のコメント

Steven Lord
Steven Lord 2020 年 4 月 9 日
disp('Here''s how you include '' in a char vector.')
disp("Or here's how to include it in a string.")
Miles Milner
Miles Milner 2020 年 4 月 9 日
I'm sorry I don't quite understand what you mean?
Image Analyst
Image Analyst 2020 年 4 月 10 日
Miles, try using double quotes:
myFolder = "C:\Users\Miles' PC\Documents\MSc Medical Physics\BP5901 MSc Project\Dicom data"
addpath(myFolder);

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeSearch Path についてさらに検索

質問済み:

2014 年 10 月 3 日

コメント済み:

2020 年 4 月 10 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by