From 1cbbfbfd7b35cfa5e7ab730155f735710e0dfa41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tony=20Tk=C3=A1=C4=8Dik?= Date: Thu, 26 Jun 2025 18:59:11 +0200 Subject: [PATCH] Updated uuidify --- bin/uuidify | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/bin/uuidify b/bin/uuidify index 72e17c1..8561002 100755 --- a/bin/uuidify +++ b/bin/uuidify @@ -1,12 +1,32 @@ -#!/usr/bin/env bash +#!/usr/bin/env nuxsh -for file in "$@"; do +## suffix:: +## Adds random UUID suffix to file names if file does not have UUID in name already. +@command suffix { + for file in "$@"; do name="${file##*/}"; if [[ ! "$name" =~ \.[0-9a-fA-F]{32}\. ]]; then - prefix="${file%.*}"; - suffix="${file##*.}"; - uuid=$(cat /proc/sys/kernel/random/uuid | tr -d "-"); - echo "$file" uuidifying - mv -v "$file" "${prefix}.${uuid}.${suffix}"; + prefix="${file%.*}"; + suffix="${file##*.}"; + uuid=$(cat /proc/sys/kernel/random/uuid | tr -d "-"); + echo "$file" uuidifying + mv -v "$file" "${prefix}.${uuid}.${suffix}"; fi -done + done +} + +## fully:: +## Renames file to random UUID if file does not have UUID in name already. +@command fully { + for file in "$@"; do + name="${file##*/}"; + if [[ ! "$name" =~ [0-9a-fA-F]{32}\. ]]; then + #prefix="${file%.*}"; + suffix="${file##*.}"; + uuid=$(cat /proc/sys/kernel/random/uuid | tr -d "-"); + echo "$file" uuidifying + mv -v "$file" "${uuid}.${suffix}"; + fi + done +} +