Skip to content

vlt.file.relativeFilename

  Find a relative file path relative to an absolute path

  RELFNAME = RELATIVEFILENAME(ABS_PATH, ABS_FILENAME [, FILE_SEPARATOR])

  Return the relative path of an filename ABS_FILENAME relative
  to a path (ABS_PATH).

  ABS_FILENAME should be a full path file name, and ABS_PATH should
  be a full path directory.

  If FILE_SEPARATOR isn't specified, it is taken to be FILESEP,
  the file separator on the platform currently running Matlab.

  Examples:
     abs_path = '/Users/myusername/Documents/';
     abs_filename = '/Users/myusername/Documents/myfolder/myfile.txt'
     relFname = vlt.file.relativeFilename(abs_path, abs_filename)
     % relFname = 'myfolder/myfile.txt'
     abs_path = '/Users/myusername/Documents/';
     abs_filename = '/Users/myusername/myfolder/myfile.txt'
     relFname = vlt.file.relativeFilename(abs_path, abs_filename)
     % relFname = '../myfolder/myfile.txt'