Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.1.0 - Português

Change language to:
English - Français - 日本語 - Русский

Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function

Ajuda do Scilab >> Arquivos : funções de Entrada/Saída > Paths - Filenames > basename

basename

strip directory and suffix from filenames

Syntax

processedfiles = basename(files[,flag [,flagexpand]])

Arguments

files

a string matrix giving a set of file names.

flag

optional boolean, used to convert the given path(s) for the current operating system. Default value is true (%t).

flagexpand

optional boolean, used to expand leading variables in paths. Only used with flag argument. Default value is true (%t).

processedFiles

a string matrix containing the processed filenames.

Description

basename(files) returns the suffices of paths, i.e. the last string following the final file separator for each path given in files.

If flag is true the paths are first converted for the current operating system (for example, 'C:/Tmp/folder' will be converted on Windows to 'C:\Tmp\folder').

if flagexpand is true, leading path variables (HOME, SCI, SCIHOME, ...) are expanded for the current operating system (for example, 'HOME\tmp' will be converted on Linux to 'home/<user>/tmp', where <user> is the current user logged on).

See more details on flag and flagexpand in pathconvert section.

Examples

files=basename('/tmp/poo')
files=basename('/tmp/poo.sci')
files=basename('/tmp/poo.bak.sci')
files=basename('/tmp/')

files=basename('C:\tmp\poo')
files=basename('C:\tmp\poo.sci')
files=basename('C:\tmp\poo.bak.sci')

files=basename('C:\tmp\')

files=basename(['SCI/etc/scilab.start', 'SCI/etc/scilab.quit'])

See also

  • listfiles — list of files
  • pathconvert — converts a path to an OS path format.
  • fileparts — returns the path, filename and extension for a file path
Report an issue
<< Paths - Filenames Paths - Filenames dirname >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Feb 25 08:52:31 CET 2020