Browse Source

add renamer

pull/11/head
Dryusdan 1 year ago
parent
commit
cf905aac3c
1 changed files with 28 additions and 0 deletions
  1. 28
    0
      rename_all_file.sh

+ 28
- 0
rename_all_file.sh View File

@@ -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

Loading…
Cancel
Save