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
|
# Author: ChatGPT
|
||||||
# Generated on: $(date '+%Y-%m-%d')
|
# Generated on: $(date '+%Y-%m-%d')
|
||||||
#
|
#
|
||||||
# This script deletes existing README files matching "* - README.md"
|
# This script recursively creates or updates a table-of-contents README file in each
|
||||||
# and then recursively creates a table-of-contents README file in each
|
|
||||||
# non-hidden directory. The file is named "Folder Name - README.md".
|
# non-hidden directory. The file is named "Folder Name - README.md".
|
||||||
#
|
#
|
||||||
# Each README includes:
|
# Each README includes:
|
||||||
# - A header with an author/date line.
|
# - An author/date header.
|
||||||
# - A header with the folder's name.
|
# - A header with the folder's name.
|
||||||
# - An alphabetically sorted list of immediate subdirectories,
|
# - An alphabetically sorted list of immediate subdirectories,
|
||||||
# with links to that subdirectory’s own README.
|
# with links to that subdirectory’s own README.
|
||||||
@ -18,24 +17,24 @@
|
|||||||
# Hidden directories (or any directory under a hidden parent such as .git)
|
# Hidden directories (or any directory under a hidden parent such as .git)
|
||||||
# are skipped.
|
# are skipped.
|
||||||
#
|
#
|
||||||
# This version optimizes by only updating the README if the content (beyond
|
# This version optimizes updates by comparing the new content (ignoring the header)
|
||||||
# the header) has changed.
|
# to the existing file and only updating if there are changes.
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
# Delete any existing README files matching "* - README.md"
|
# If you want to remove existing README files, comment out or remove the next line.
|
||||||
find . -type f -name '* - README.md' -delete
|
# find . -type f -name '* - README.md' -delete
|
||||||
|
|
||||||
# Set the base directory (change "." if necessary)
|
# Set the base directory (change "." if necessary)
|
||||||
base_dir="."
|
base_dir="."
|
||||||
|
|
||||||
# Recursively process every directory starting from base_dir.
|
# Recursively process every directory starting from base_dir.
|
||||||
find "$base_dir" -type d -print0 | while IFS= read -r -d '' dir; do
|
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
|
if [[ "$(basename "$dir")" == .* ]] || [[ "$dir" == *"/.git"* ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
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
|
if [ "$dir" = "$base_dir" ]; then
|
||||||
base=$(basename "$PWD")
|
base=$(basename "$PWD")
|
||||||
else
|
else
|
||||||
@ -49,8 +48,7 @@ find "$base_dir" -type d -print0 | while IFS= read -r -d '' dir; do
|
|||||||
tmpfile=$(mktemp)
|
tmpfile=$(mktemp)
|
||||||
|
|
||||||
# Write the header into the temporary file.
|
# Write the header into the temporary file.
|
||||||
# (The header includes the current date; note that for optimization
|
# (We include the date here but will ignore it when comparing changes.)
|
||||||
# we will ignore the header when comparing changes.)
|
|
||||||
{
|
{
|
||||||
echo "Generated by ChatGPT on $(date '+%Y-%m-%d')"
|
echo "Generated by ChatGPT on $(date '+%Y-%m-%d')"
|
||||||
echo ""
|
echo ""
|
||||||
@ -62,7 +60,7 @@ find "$base_dir" -type d -print0 | while IFS= read -r -d '' dir; do
|
|||||||
# Process Subdirectories
|
# Process Subdirectories
|
||||||
#########################
|
#########################
|
||||||
subdirs=()
|
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
|
while IFS= read -r -d '' subdir; do
|
||||||
sub_basename=$(basename "$subdir")
|
sub_basename=$(basename "$subdir")
|
||||||
if [ -n "$sub_basename" ]; then
|
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"
|
echo "## Subdirectories" >> "$tmpfile"
|
||||||
for sub in "${sorted_subdirs[@]}"; do
|
for sub in "${sorted_subdirs[@]}"; do
|
||||||
# Build the link to the subdirectory's README file.
|
# Build the link to the subdirectory's README file.
|
||||||
# The link format is: [[Subfolder/Subfolder - README]]
|
# Format: [[Subfolder/Subfolder - README]]
|
||||||
line="- [[${sub}/${sub} - README]]"
|
line="- [[${sub}/${sub} - README]]"
|
||||||
# Use printf with %s to avoid issues with leading dashes.
|
|
||||||
printf "%s\n" "$line" >> "$tmpfile"
|
printf "%s\n" "$line" >> "$tmpfile"
|
||||||
done
|
done
|
||||||
echo "" >> "$tmpfile"
|
echo "" >> "$tmpfile"
|
||||||
@ -107,12 +104,11 @@ find "$base_dir" -type d -print0 | while IFS= read -r -d '' dir; do
|
|||||||
echo "" >> "$tmpfile"
|
echo "" >> "$tmpfile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If the README file exists, compare its body (ignoring the header)
|
# If the README file exists, compare its body (ignoring the header) with the new content.
|
||||||
# with the new content. The header is the first line (or first two lines,
|
# Here, we assume the header is the first two lines (the attribution and a blank line).
|
||||||
# if you consider the blank line). Here, we compare starting from line 3.
|
|
||||||
if [ -f "$readme" ]; then
|
if [ -f "$readme" ]; then
|
||||||
if diff -q <(tail -n +3 "$tmpfile") <(tail -n +3 "$readme") >/dev/null; 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"
|
rm "$tmpfile"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user