FileNameDrop

FileNameDrop["name",n]
drops the first n path elements in the file name .

FileNameDrop["name",-n]
drops the last n path elements in the file name .

FileNameDrop["name",{m,n}]
drops elements m through n in the file name .

FileNameDrop["name"]
drops the last path element in the file name .

Details and OptionsDetails and Options

  • FileNameDrop by default assumes that path elements are separated by pathname separators suitable for your operating system.
  • FileNameDrop[,OperatingSystem->"os"] uses the conventions of the specified operating system. Possible choices are , , and .
  • FileNameDrop just operates on names of files; it does not actually search for the file specified.
  • If more elements are specified to be dropped than are present, FileNameDrop just drops those that are present.

ExamplesExamplesopen allclose all

Basic Examples  (2)Basic Examples  (2)

Find the parent directory:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

On Windows, the share name is treated as a single unit:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2008
(7.0)