1 # Create BookStack Pages from HTML Files
3 This script will scan through a local `files/` directory for `*.html` files then create pages for each within BookStack, where the name of the files is used for the name of the page and the contents of the file is used for the BookStack page content.
5 **This is a very simplistic single-script-file example of sending data via PowerShell** and was written with little prior PowerShell knowledge.
9 You will need PowerShell available.
10 You will also need BookStack API credentials (TOKEN_ID & TOKEN_SECRET) at the ready.
12 **This script was written using PowerShell (Core) 7.2.10 on Linux".
14 A `docker-compose.yml` file exists just as a convenient way to run PowerShell, particularly for Linux users.
18 First of all, download the `files-to-pages.ps1` script file.
19 Then you'll need to setup your environment to point to your BookStack instance with the right credentials:
23 # ALTERNATIVELY: Open the script and edit the variables at the top
24 Set-Item -Path env:BS_URL -Value "https://bookstack.example.com" # Set to be your BookStack base URL
25 Set-Item -Path env:BS_TOKEN_ID -Value "abc123" # Set to be your API token_id
26 Set-Item -Path env:BS_TOKEN_SECRET -Value "123abc" # Set to be your API token_secret
29 Once configured, then create a `files` folder containing HTML files you want to upload as pages. See the `files` directory of this repo as a very basic example.
30 Now it's time to run the script like so:
33 ./files-to-pages.ps1 <target_book_id>
39 # Upload HTML files in the relative `files` directory as BookStack pages
40 # into the existing BookStack "Book" that has an ID of 5:
41 ./files-to-pages.ps1 5