dir (Directory)
Use the directory commands to list folders and files, create folders, and delete folders within the media/
or design/
locations on the file system. For security and stability reasons, these are the only locations accessible by the Lua libraries.
The media/
folder is the location for all media files, while the design/
folder is the location where uncompressed design configuration files reside while a design is being emulated or running on a Q-SYS Core processor. (It is not intended for storage of user-created design files, and is not remotely accessible.)
List directories and files in a media/
or design/
path.
Syntax
dir.get(path)
Arguments
path : String. Must begin with /media
or design/
. Surround the path with quotes.
Example
directory = "media/Audio"
temp = dir.get(directory)
for i,v in ipairs(temp) do
print (directory.."/"..v.name)
end
Debug Output
Starting Script media/Audio/01 My Special Song.mp3 media/Audio/ringout.wav media/Audio/16 Annoying Song.mp3 media/Audio/07 Happy Happy Joy Joy.mp3
Create a new folder within a media/
or design/
path.
Syntax
dir.create(path)
Arguments
path : String. Must begin with /media
or design/
. Surround the path with quotes.
Example
directory = "media/Audio/New"
dir.create(directory)
Remove an empty folder within a media/
or design/
path.
Syntax
dir.remove(path)
Arguments
path : String. Must begin with /media
or design/
. Surround the path with quotes.
Note: The folder you are removing must be empty. See the Example section for an iterative method to remove files before removing the folder.
Example
If the folder you intend to delete contains files, you must remove them first using os.remove()
. For example:
directory = "media/Audio/New"
temp = dir.get(directory)
for i,v in ipairs(temp) do
os.remove(directory.."/"..v.name)
end
Then, use dir.remove()
to remove the now empty folder:
dir.remove(directory)