vault backup: 2025-02-12 10:18:39
This commit is contained in:
parent
6072abbf9f
commit
b8e589b05c
@ -1,17 +0,0 @@
|
||||
Generated by ChatGPT on 2025-02-12
|
||||
|
||||
# Table of Contents for 300s School
|
||||
|
||||
## Subdirectories
|
||||
- [[ME 2016 - Nonlinear Dynamical Systems 1/ME 2016 - Nonlinear Dynamical Systems 1 - README]]
|
||||
- [[ME 2046 - Digital Control Theory/ME 2046 - Digital Control Theory - README]]
|
||||
- [[ME 2085 - Graduate Seminar/ME 2085 - Graduate Seminar - README]]
|
||||
- [[ME 2150 - High Assurance Cyber-Physical Systems/ME 2150 - High Assurance Cyber-Physical Systems - README]]
|
||||
- [[ME 3100 - Engineering Research and Leadership Management/ME 3100 - Engineering Research and Leadership Management - README]]
|
||||
- [[NUCE 2100 - Fundamentals of Nuclear Engineering/NUCE 2100 - Fundamentals of Nuclear Engineering - README]]
|
||||
- [[NUCE 2103 - Integration of Plant Systems with the Reactor Core/NUCE 2103 - Integration of Plant Systems with the Reactor Core - README]]
|
||||
- [[NUCE 2113 - Radiation Detection and Measurement/NUCE 2113 - Radiation Detection and Measurement - README]]
|
||||
|
||||
## Files
|
||||
- [[reddup.sh]]
|
||||
|
||||
32
reddup.sh
32
reddup.sh
@ -3,12 +3,11 @@
|
||||
# Author: ChatGPT
|
||||
# Generated on: $(date '+%Y-%m-%d')
|
||||
#
|
||||
# This script deletes existing README files matching "* - README.md"
|
||||
# and then recursively creates a table-of-contents README file in each
|
||||
# This script recursively creates or updates a table-of-contents README file in each
|
||||
# non-hidden directory. The file is named "Folder Name - README.md".
|
||||
#
|
||||
# Each README includes:
|
||||
# - A header with an author/date line.
|
||||
# - An author/date header.
|
||||
# - A header with the folder's name.
|
||||
# - An alphabetically sorted list of immediate subdirectories,
|
||||
# with links to that subdirectory’s own README.
|
||||
@ -18,24 +17,24 @@
|
||||
# Hidden directories (or any directory under a hidden parent such as .git)
|
||||
# are skipped.
|
||||
#
|
||||
# This version optimizes by only updating the README if the content (beyond
|
||||
# the header) has changed.
|
||||
# This version optimizes updates by comparing the new content (ignoring the header)
|
||||
# to the existing file and only updating if there are changes.
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
# Delete any existing README files matching "* - README.md"
|
||||
find . -type f -name '* - README.md' -delete
|
||||
# If you want to remove existing README files, comment out or remove the next line.
|
||||
# find . -type f -name '* - README.md' -delete
|
||||
|
||||
# Set the base directory (change "." if necessary)
|
||||
base_dir="."
|
||||
|
||||
# Recursively process every directory starting from base_dir.
|
||||
find "$base_dir" -type d -print0 | while IFS= read -r -d '' dir; do
|
||||
# Skip hidden directories or those under hidden directories (e.g. .git)
|
||||
# Skip directories that are hidden or are within a hidden directory (like .git)
|
||||
if [[ "$(basename "$dir")" == .* ]] || [[ "$dir" == *"/.git"* ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# For the top-level directory, use its actual name (using $PWD)
|
||||
# For the top-level directory, use its actual name (using $PWD) instead of "."
|
||||
if [ "$dir" = "$base_dir" ]; then
|
||||
base=$(basename "$PWD")
|
||||
else
|
||||
@ -49,8 +48,7 @@ find "$base_dir" -type d -print0 | while IFS= read -r -d '' dir; do
|
||||
tmpfile=$(mktemp)
|
||||
|
||||
# Write the header into the temporary file.
|
||||
# (The header includes the current date; note that for optimization
|
||||
# we will ignore the header when comparing changes.)
|
||||
# (We include the date here but will ignore it when comparing changes.)
|
||||
{
|
||||
echo "Generated by ChatGPT on $(date '+%Y-%m-%d')"
|
||||
echo ""
|
||||
@ -62,7 +60,7 @@ find "$base_dir" -type d -print0 | while IFS= read -r -d '' dir; do
|
||||
# Process Subdirectories
|
||||
#########################
|
||||
subdirs=()
|
||||
# Find immediate subdirectories (depth 1), skipping hidden ones.
|
||||
# Find immediate subdirectories (depth 1) in the current directory, skipping hidden ones.
|
||||
while IFS= read -r -d '' subdir; do
|
||||
sub_basename=$(basename "$subdir")
|
||||
if [ -n "$sub_basename" ]; then
|
||||
@ -76,9 +74,8 @@ find "$base_dir" -type d -print0 | while IFS= read -r -d '' dir; do
|
||||
echo "## Subdirectories" >> "$tmpfile"
|
||||
for sub in "${sorted_subdirs[@]}"; do
|
||||
# Build the link to the subdirectory's README file.
|
||||
# The link format is: [[Subfolder/Subfolder - README]]
|
||||
# Format: [[Subfolder/Subfolder - README]]
|
||||
line="- [[${sub}/${sub} - README]]"
|
||||
# Use printf with %s to avoid issues with leading dashes.
|
||||
printf "%s\n" "$line" >> "$tmpfile"
|
||||
done
|
||||
echo "" >> "$tmpfile"
|
||||
@ -107,12 +104,11 @@ find "$base_dir" -type d -print0 | while IFS= read -r -d '' dir; do
|
||||
echo "" >> "$tmpfile"
|
||||
fi
|
||||
|
||||
# If the README file exists, compare its body (ignoring the header)
|
||||
# with the new content. The header is the first line (or first two lines,
|
||||
# if you consider the blank line). Here, we compare starting from line 3.
|
||||
# If the README file exists, compare its body (ignoring the header) with the new content.
|
||||
# Here, we assume the header is the first two lines (the attribution and a blank line).
|
||||
if [ -f "$readme" ]; then
|
||||
if diff -q <(tail -n +3 "$tmpfile") <(tail -n +3 "$readme") >/dev/null; then
|
||||
# No change in the "body" of the file; do not update.
|
||||
# No change in the body; do not update.
|
||||
rm "$tmpfile"
|
||||
continue
|
||||
fi
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user