PathName is a utility class for manipulating file names and paths. It expects a path to a file, and lets you access parts of that file path.
returns just the name of the file itself; i.e. everything after the last slash in the full path.
returns the name of the file itself without the file extension.
returns the file extension, i.e. everything after the last full-stop in the -fileName.
returns the full path up to the file name itself; i.e. everything up to and including the last slash. This is handy e.g. for storing several files in the same folder.
you MUST have correctly initialized the scroot classvar for this to know what it is relative to !
returns only the name of the folder that the file is in; i.e. everything in between the last but one and the last slash.
returns the full path name that PathName contains.
returns a list of all the files+folders inside the folder represented by this path.
returns a list of all the files in the folder represented by this path.
returns a list of all the subfolders of the folder represented by this path.
returns a Boolean indicating whether or not the path represents a file (not a folder).
returns a Boolean indicating whether or not the path represents a folder (not a file).
Iterates over all files found in the pathname, including ones in subfolders.
returns a list of all the folder names contained in the pathname itself.
if path is an absolute path, returns the disk name; else a blank string.
Path concatenation operator - useful for avoiding doubling-up slashes unnecessarily.
returns a number at the end of PathName. Returns zero if there is no number.
returns -fullPath without any numbers at the end.
generates a sensible next name for a file by incrementing a number at the end of PathName, or by adding one if there is none. This is useful for recording files with consecutive names, and e.g. to generate a new filename when you don't want to overwrite an existing file with the current name.
Here is an example that uses many instance methods. Just pick any file to see all the parts of its path.
Choose a soundfile to put into the library, using its foldername and filename.
Save three tables in the same folder. Note: The file name chosen in the dialog is ignored! The files are always named table1, table2, table3.