mirror of
https://github.com/tonydamage/nux-env.git
synced 2025-12-11 13:24:28 +01:00
Updated uuidify
This commit is contained in:
parent
5da9559ff0
commit
1cbbfbfd7b
1 changed files with 28 additions and 8 deletions
26
bin/uuidify
26
bin/uuidify
|
|
@ -1,6 +1,9 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env nuxsh
|
||||||
|
|
||||||
for file in "$@"; do
|
## suffix:: <file>
|
||||||
|
## Adds random UUID suffix to file names if file does not have UUID in name already.
|
||||||
|
@command suffix {
|
||||||
|
for file in "$@"; do
|
||||||
name="${file##*/}";
|
name="${file##*/}";
|
||||||
if [[ ! "$name" =~ \.[0-9a-fA-F]{32}\. ]]; then
|
if [[ ! "$name" =~ \.[0-9a-fA-F]{32}\. ]]; then
|
||||||
prefix="${file%.*}";
|
prefix="${file%.*}";
|
||||||
|
|
@ -9,4 +12,21 @@ for file in "$@"; do
|
||||||
echo "$file" uuidifying
|
echo "$file" uuidifying
|
||||||
mv -v "$file" "${prefix}.${uuid}.${suffix}";
|
mv -v "$file" "${prefix}.${uuid}.${suffix}";
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
## fully:: <file>
|
||||||
|
## 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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue