Remove defase_draws.sh script and improve file renaming logic in tasks.sh for better handling of duplicate files and proper extension assignment.
This commit is contained in:
@@ -1,7 +0,0 @@
|
|||||||
#!/etc/profiles/per-user/jawz/bin/bash
|
|
||||||
|
|
||||||
cd /home/jawz/Development/Websites/portfolio/content/friends || exit
|
|
||||||
|
|
||||||
for file in [0-9][0-9][0-9]_*; do
|
|
||||||
mv "$file" "$(printf '%03d_%s' $((10#${file%%_*} + 1)) "${file#*_}")"
|
|
||||||
done
|
|
||||||
@@ -155,18 +155,22 @@ while IFS= read -r file; do
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
echo "The file $(basename "$file")" \
|
echo "The file $(basename "$file")" \
|
||||||
"will be renamed, the propper extension is $correct_ext"
|
"will be renamed, the proper extension is $correct_ext"
|
||||||
new_name="$filename".$correct_ext
|
new_name="$filename".$correct_ext
|
||||||
if command mv -n "$(dirname "$file")"/{"$(basename "$file")","$new_name"}; then
|
dest_path="$(dirname "$file")/$new_name"
|
||||||
|
|
||||||
|
if [ ! -e "$dest_path" ]; then
|
||||||
|
mv "$file" "$dest_path"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
file_hash="$(sha256sum "$file" | gawk '{ print $1 }')"
|
file_hash="$(sha256sum "$file" | gawk '{ print $1 }')"
|
||||||
if ! echo "$file_hash $(dirname "$file")/$new_name" | sha256sum -c; then
|
if echo "$file_hash $dest_path" | sha256sum -c --quiet; then
|
||||||
continue
|
echo "Deleting duplicate (same hash): $file"
|
||||||
|
rm "$file"
|
||||||
|
else
|
||||||
|
echo "WARNING: $file and $dest_path have different content, skipping"
|
||||||
fi
|
fi
|
||||||
echo "deleting duplicated: $file"
|
|
||||||
rm "$file"
|
|
||||||
done < <(fd . "${directories[@]}" -d 1 -tf)
|
done < <(fd . "${directories[@]}" -d 1 -tf)
|
||||||
|
|
||||||
files_home_clean=(.pki HuionCore.pid DriverUI.pid huion.log)
|
files_home_clean=(.pki HuionCore.pid DriverUI.pid huion.log)
|
||||||
|
|||||||
Reference in New Issue
Block a user