add renamer
This commit is contained in:
parent
fde735c88a
commit
cf905aac3c
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function generate_random_char {
|
||||||
|
echo $( dd if=/dev/urandom bs=16 count=1|base64) > /tmp/rename_all_image
|
||||||
|
cp /tmp/rename_all_image /tmp/rename_all_image.back
|
||||||
|
sed -ie 's/[!@#\+\/$%^&*()=]//g' /tmp/rename_all_image.back
|
||||||
|
NEW_FILENAME=$(cat /tmp/rename_all_image.back)
|
||||||
|
EXTENSION=$(echo $img | cut -f 2 -d '.')
|
||||||
|
echo $NEW_FILENAME"."$EXTENSION
|
||||||
|
}
|
||||||
|
|
||||||
|
function move_file {
|
||||||
|
NEW_FILE=$(generate_random_char)
|
||||||
|
filepath=$2
|
||||||
|
IMG=$1
|
||||||
|
#echo $filepath"/"$NEW_FILE
|
||||||
|
if [ ! -f $filepath"/"$NEW_FILE ]; then
|
||||||
|
#mv $IMG $NEW_FILE
|
||||||
|
mv $IMG $filepath"/"$NEW_FILE
|
||||||
|
else
|
||||||
|
move_file $IMG
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
for img in `ls $1/*`; do
|
||||||
|
filepath=$1
|
||||||
|
move_file $img $filepath
|
||||||
|
done
|
Reference in New Issue