Code covered by the BSD License  

Highlights from
pushd

  • popd POPD Pops you back up in the PUSHD stack
  • pushd(varargin) PUSHD Changes MATLAB working directory to the one specified, or to the folder containing the specified file
  • View all files

5.0

5.0 | 2 ratings Rate this file 5 Downloads (last 30 days) File Size: 3.21 KB File ID: #8103

pushd

by Peter (PB) Bodin

 

26 Jul 2005 (Updated 03 Dec 2009)

MATLAB version of pushd & popd, both available in UNIX/Linux and DOS. Adds some Matlab specific feat

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information
Description

PUSHD(directory/file-spec) stores the current working directory and changes current directory to the one specified in the string directory-spec. To get back to the stored directory call POPD, see help popd. PUSHD cal also be used to jump to a directory containing a specified file.
PUSHD stores the current directory. Go back to the pushed directory using POPD, see help popd.

PUSHD stores a stack of pushed directories. Calling POPD will pop you one step up the stack.

These two files, PUSHD and POPD are intended to mimic the functions with the same names in UNIX/Linux and DOS.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
GOTO: Go to a directory containing a file

MATLAB release MATLAB 7.0.1 (R14SP1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
09 Aug 2005 John D'Errico

Its quite nice, allowing me to hop around directories
simply, then pop back. I like the ability to go to a
directory that holds an existing function.

I did want to be able to do several pushes, then pop
back up the stack. I might have given it a 5 rating had
this been possible.

There is a minor bug however. The initial addpref call was
missing a third argument.

if ~ispref('pushd','pushed')
    addpref('pushd','pushed',pwd);
end

11 Aug 2005 Peter Bodin

Please do not download the version from 2005-08-10. This version introduced another bug. Wait until the date 2005-08-11 or later is registered under the Changes heading below. /PB

14 Aug 2005 John D'Errico

With the bugfix, capability of a stack and some time to
test it out, its now time to upgrade my last rating. Its a
clean code that does its job well.

Please login to add a comment or rating.
Updates
27 Jul 2005

Changed from using setappdata to setpref in order to make the pushed dir available in separate MATLAB sessions.

10 Aug 2005

Fixed a bug. Added stack functionality.

11 Aug 2005

Simplified the code.

12 Aug 2005

Bug fix.

15 Aug 2005

Added some error trapping.

03 Dec 2009

Added some error trapping to adapt to new outputs of WHICH for built-in functions.

Tag Activity for this File
Tag Applied By Date/Time
potw Shari Freedman 11 Dec 2009 09:39:17
pick of the week Jiro Doke 11 Feb 2011 20:09:38

Contact us at files@mathworks.com