nix-configs

Personal NixOS and home-manager configuration files
Log | Files | Refs

commit cc490d1c4fea800778e925827a9bdc695aa6a625
parent 64e31bfcd941d9fcf776061c82c780c2e5e3500d
Author: breadcat <breadcat@users.noreply.github.com>
Date:   Tue, 28 Apr 2026 11:40:07 +0100

Update payslip script to reflect new job format

Diffstat:
Mscripts/payslips.nix | 14+++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/scripts/payslips.nix b/scripts/payslips.nix @@ -5,21 +5,29 @@ let # Default destination directory, or use argument destination_default="/tank/paperwork/personal/workplace/wages" destination_dir="''${1:-$destination_default}" + pdftotext_bin="${pkgs.poppler-utils}/bin/pdftotext" # Process matching files - for file in ./*-[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9].pdf; do + for file in ./????????-????-????-????-????????????-result.pdf; do [[ -e "$file" ]] || continue # Skip if no match filename=$(basename "$file") # Extract the date - if [[ "$filename" =~ ([0-9]{2})-([0-9]{2})-([0-9]{4})\.pdf$ ]]; then + date=$("$pdftotext_bin" "$file" - | grep -oE '[0-9]{2}-[0-9]{2}-[0-9]{4}' | head -n1) + if [[ "$date" =~ ^([0-9]{2})-([0-9]{2})-([0-9]{4})$ ]]; then day="''${BASH_REMATCH[1]}" month="''${BASH_REMATCH[2]}" year="''${BASH_REMATCH[3]}" new_filename="''${year}-''${month}-''${day}.pdf" + + # Avoid overwriting existing files + if [[ -e "$destination_dir/$new_filename" ]]; then + new_filename="''${year}-''${month}-''${day}-$(date +%s).pdf" + fi + mv "$file" "$destination_dir/$new_filename" echo "Moved: $file to $destination_dir/$new_filename" else - echo "Skipped (no valid date in name): $filename" + echo "Skipped (no valid date found in PDF): $filename" fi done '';