Thread Subject: rmpath problem

Subject: rmpath problem

From: Koos Spee

Date: 25 Nov, 2009 11:52:20

Message: 1 of 6

I want to remove the path C:\temp\ whitin a script

rmpath(' C:\temp\') obvious works fine. However when I run the script for a second time (or when path is already removed) I get the following warning:

Warning: "C:\temp\'" not found in path.

Can this be solved? E.g. can I check if a directory is in the "search path"

Subject: rmpath problem

From: ImageAnalyst

Date: 25 Nov, 2009 12:48:18

Message: 2 of 6

On Nov 25, 6:52 am, "Koos Spee" <bmx_...@hotmail.com> wrote:
> I want to remove the path C:\temp\ whitin a script
>
> rmpath(' C:\temp\') obvious works fine. However when I run the script for a second time (or when path is already removed) I get the following warning:
>
> Warning: "C:\temp\'" not found in path.
>
> Can this be solved? E.g. can I check if a directory is in the "search path"
-----------------------------------------------------
Either wrap it in a try
try
  rmpath(folder);
catch
end

or check existence beforehand:
if exist(folder, 'dir')
  rmpath(folder);
end

Subject: rmpath problem

From: Bruno Luong

Date: 25 Nov, 2009 12:53:07

Message: 3 of 6


> or check existence beforehand:
> if exist(folder, 'dir')
> rmpath(folder);
> end

rmpath removes the folder from Matlab search path but does not delete the path itself. So check with EXIST is not consistent. Rather use PATH command.

Bruno

Subject: rmpath problem

From: Jos (10584)

Date: 25 Nov, 2009 13:00:24

Message: 4 of 6

"Koos Spee" <bmx_360@hotmail.com> wrote in message <hej5pk$731$1@fred.mathworks.com>...
> I want to remove the path C:\temp\ whitin a script
>
> rmpath(' C:\temp\') obvious works fine. However when I run the script for a second time (or when path is already removed) I get the following warning:
>
> Warning: "C:\temp\'" not found in path.
>
> Can this be solved? E.g. can I check if a directory is in the "search path"

It is only a warning, not an error. This might be instructive:

addpath('c:\temp')
rmpath('c:\temp')
rmpath('c:\temp')
% Warning: "c:\temp;" not found in path.
% > In rmpath at 58
warning('off','MATLAB:rmpath:DirNotFound')
rmpath('c:\temp')
warning('on','MATLAB:rmpath:DirNotFound')
rmpath('c:\temp')
% Warning: "c:\temp;" not found in path.
% > In rmpath at 58

See
help warning
help lastwarn

Jos

Subject: rmpath problem

From: ImageAnalyst

Date: 25 Nov, 2009 13:16:37

Message: 5 of 6

You're right Bruno - I had incorrectly assumed he was deleting the
folder from the hard drive rather than just getting rid of it from the
search path.

Subject: rmpath problem

From: Jan Simon

Date: 25 Nov, 2009 14:03:19

Message: 6 of 6

Dear Koos!

> rmpath(' C:\temp\') obvious works fine. However when I run the script for a second time (or when path is already removed) I get the following warning:
>
> Warning: "C:\temp\'" not found in path.
>
> Can this be solved? E.g. can I check if a directory is in the "search path"

PathCell = strread(path, '%s', 'delimiter', pathsep);
if any(strcmpi(PathCell, 'C:\temp'))
  rmpath('C:\temp');
end

Consider that the path has not trailing file separator.

Kind regards, Jan

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
rmpath path Koos Spee 25 Nov, 2009 06:54:05
rssFeed for this Thread

Contact us at files@mathworks.com