Is there a path in the string?

hi,
a: example: f='\report\
b: example =f='c:\root\report\
how can i identify the string with case "a" or with "b"?
in the case 'a' i see a folder..
in case 'b' i see a path with folder

5 件のコメント

Govind KM
Govind KM 2023 年 6 月 16 日
Can you explain your question in a bit more detail?
shamal
shamal 2023 年 6 月 16 日
編集済み: shamal 2023 年 6 月 16 日
G='FOLDER\'
H='C:\MATLAB\'
ok next step
if G is only a folder
Result=strcat(H,G)
if G is a path (G:\PIPPO\FOLDER\)
Result=H;
I could search if there is a ':' but is not professional solution
if strfind(G,':')
Result=H;
else
Result=strcat(H,G)
end
Mathieu NOE
Mathieu NOE 2023 年 6 月 16 日
why looking for ':/' char array would not be professionnal ?
shamal
shamal 2023 年 6 月 19 日
it seems too simple
Mathieu NOE
Mathieu NOE 2023 年 6 月 20 日
why something simple could not be used ?

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

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2023 年 6 月 16 日

1 投票

You can utilize the exist() function.
Assume you are at the c:\root folder, and there is a \report sub-folder
exist('\report','dir') will return 0
exist('c:\root\report','dir') will return 7, since 'c:\root\report' is the full path of a folder.
Please note, exist('report','dir') will also return 7.

カテゴリ

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

質問済み:

2023 年 6 月 16 日

コメント済み:

2023 年 6 月 20 日

Community Treasure Hunt

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

Start Hunting!

Translated by