IBM Z and LinuxONE - IBM Z

IBM Z

The enterprise platform for mission-critical applications brings next-level data privacy, security, and resiliency to your hybrid multicloud.

 View Only

SHARE Proceedings Made More Usable

By Lionel Dyck posted Thu September 19, 2024 02:04 PM

  

SHARE has released a consolidated zip file with all the presentations and handout files for SHARE Kansas City so those with access can download and peruse them offline.

What is missing is a index.html file to make access easier.

So - with some help from CoPilot - I have a shell script that will list all the files in a directory, so it can be used for more than just the SHARE Proceedings) and generate an index.html to easily access all the files (each opening in a new tab). The only thing that needs to be done after running the script is to edit it to update the title and h1 tags.

Here is the script 

#!/bin/bash
 
# Directory to list files from
DIR="."
 
# Output HTML file
OUTPUT="index.html"
 
# Get the base name of the directory
DIR_NAME=$(basename "$DIR")
 
# Start HTML file with title
echo "<html><head><title>Index of $DIR_NAME</title></head><body>" > $OUTPUT
echo "<h1>Index of $DIR_NAME</h1><ul>" >> $OUTPUT
 
# Loop through each file in the directory
for FILE in "$DIR"/*; do
  # Remove leading and trailing quotes from the filename
  CLEAN_FILE=$(echo "$FILE" | sed 's/^"//' | sed 's/"$//')
  
  # Get the base name of the file
  BASE_NAME=$(basename "$CLEAN_FILE")
  
  # Add the file as a link in the HTML file, opening in a new tab
  echo "<li><a href=\"$CLEAN_FILE\" target=\"_blank\">$BASE_NAME</a></li>" >> $OUTPUT
done
 
# End HTML file
echo "</ul></body></html>" >> $OUTPUT
 
echo "index.html has been generated."

0 comments
7 views

Permalink