# Create m3u Files

As the name implies, this function is used to create one or more m3u files.

When the Setting defaulted based on Album or Playlist Open Mode option is set, this function mimics the UI equivalents.

> When in Album Mode or when running in the Batch Processor, the function will create m3u files in each folder containing files in the current selection. Only files in the current selection will be represented in the created files. If the album name is unique for each represented folder, the created file will be named album name. If the album name is not unique, the created file will be named Yate.

> When in Playlist Mode, a file save dialog will appear where you select the name and location of the file to be produced. The produced file will contain an entry for every file in the file list regardless of the current selection.

When the Setting defaulted based on Album or Playlist Open Mode option is not set, you have far more options. Note that when not set the function only operates on the current selection.

You choose to create a single playlist in a specified folder or to create one playlist in each folder containing files. When specifying a folder the path may contain any of the escape sequences described in Escape Sequences. When creating a playlist in each folder you can choose to use the album field as the file name. Regardless as to whether this option is set or not, an album name will only be used if it is consistant across all tracks. Note that the specified path must resolve to be absolute (/) or relative to the home folder (~/. The path must have an m3u filename extension. The path will be created if it does not exist.

You can specify a filename to be used if the album name is not being used or is not eligible. If a filename is not specified and one is required, Yate will be used. The specified filename may contain any of the escape sequences described in Escape Sequences.

An attempt will be made to have each entry in a playlist be relative to the playlist file. This is only done if all tracks in a playlist are in the same folder as the playlist or in a subfolder of the folder containing the playlist. You can disable this functionality by selecting the Always write full paths option. When this option is enabled all entries will be fully formed absolute paths.

Three types of m3u files can be produced. In Standard m3u files, each line describes a file. Extended m3u files provided duration and title metadata by writing the metadata on comment lines. Yate m3u files write Yate Track IDs on comment lines which can assist in the ability to correct m3u files when files are renamed. More information on the file formats can be found in m3u File Formats.

By default, entries are placed into the produced files in the order in which the tracks are sorted. This reflects the current order displayed in the main window or when batch processing, the default sort order. If you want to have the order randomized you can select the Randomize track order option.

It is possible that you are producing playlists which will be accessed on an external file system which will have a different path when accessed. You can choose to relocate each track's location by replacing leftmost portions of a path with a different pattern. The patterns may contain any of the escape sequences described in Escape Sequences. Note that the patterns are case sensitive. It is strongly recommended that both the from and to pattern end with a valid path component separator (/). This option is only enabled when you have chosen the Always write full paths option.

> eg. replace /Volumes/Music/ with /NasDrive/Tracks/

When producing the file, Yate will save it with a .m3u extension if the contents of the file can be saved with the encoding specified in Preferences - Cur Sheets/m3u Files. If the filenames contain characters outside the encoding, the file will be saved as a UTF8 file with the extension .m3u8. Some devices cannot play m3u8 files. Note that if an m3u file is created and an m3u8 file of the same name exists, it will be deleted. If an m3u8 file is created, if an m3u file of the same name exists, it will be deleted.

While the action test state is not set for this statement, if an error occured the Action Error Text named variable will contain the error message.

This function is not valid during Grouped execution.