> For the complete documentation index, see [llms.txt](https://bonsai-docs.gitbook.io/bonsai-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bonsai-docs.gitbook.io/bonsai-docs/bonsai-radio/media-setup/media-scanner.md).

# Media Scanner

Bonsai Radio includes a media scanner that automatically creates a library containing all songs, advertisements and jingles used by the resource.

The scanner prevents server owners from having to manually list every audio file inside the configuration.

### What the Scanner Does

The media scanner searches the Bonsai Radio media folders and generates:

```
data/media_library.json
```

The generated library contains information such as:

* File location
* Media type
* Radio station
* Audio duration
* Song title
* Artist
* Cover image
* Advertisement files
* Jingle files

The resource reads this file when Bonsai Radio starts.

### Running the Scanner

Open the Bonsai Radio resource folder and run:

```
auto_scan_media.bat
```

A command window will open and begin scanning the media folders.

When the scan finishes, a summary will be displayed.

Example:

```
Scan completed

Songs: 183
Ads: 24
Jingles: 16
```

The generated media library can be found here:

```
data/media_library.json
```

### When Should the Scanner Be Run?

Run the scanner whenever you:

* Add a song
* Remove a song
* Rename an audio file
* Move a song to another station
* Add an advertisement
* Remove an advertisement
* Add a jingle
* Remove a jingle
* Create a new media folder
* Change media metadata

After running the scanner, restart Bonsai Radio.

```
restart bonsai_radio
```

### Media Library Missing

If Bonsai Radio displays a warning similar to:

```
CONFIG WARNING: RADIO_01_CLASS_ROCK uses folder-based media but data/media_library.json is missing or invalid. Run scan_media.bat.
```

it means the media library is missing, empty or could not be read.

To resolve this:

1. Stop Bonsai Radio.
2. Run `scan_media.bat`.
3. Confirm that `data/media_library.json` was created.
4. Start or restart Bonsai Radio.

```
restart rs_radio
```

### Deleted Songs Still Playing

When an audio file is deleted, it must also be removed from the generated media library.

Run:

```
scan_media.bat
```

The scanner will rebuild the library and automatically remove files that no longer exist.

Restart Bonsai Radio after the scan.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://bonsai-docs.gitbook.io/bonsai-docs/bonsai-radio/media-setup/media-scanner.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
