Dear developers,
I have an issue with my script switching from Android 9 to 10 (devices from a Umidigi S3 Pro to a Umidigi F2).
I have installed Bosybox App on the first and Busybox Magisk module on the latter.
Now the script does not work because the command:
list=(`busybox find "$dirs" -type f -name *.$ext`)
returns an empty array.
This is the complete script:
#!/system/bin/sh
echo
if test "$1" = ""; then
echo "Randomfile script by Uranya <@uranya7x> v1.4 01.01.2021"
echo "Usage:"
echo "sh randomfile.sh <sourcedir> <extension> <destdir>"
exit 1
fi
dirs=$1
ext=$2
dird=$3'/'
dest=$dird'random'
delim1=""
delim2=""
last='last.txt'
# create filename's array
IFS=$'\n'
list=(`busybox find "$dirs" -type f -name *.$ext`)
# count number of files
num=${#list[@]}
# generate random number in range 1-NUM
let "ran=(${RANDOM} % ${num})+ 1"
echo Random from $num files is $ran
sour=${list[ran]}
sourn=${sour#$dirs}
sourn=${sourn:1:${#sourn}}
date=$(date +"%Y.%m.%d %H:%M")
day=$(date +"%d")
hour=$(date +"%H")
minute=$(date +"%M")
message='---------------------------------------\n'$date' - '$num' >>> '$ran'\n'$delim1$sourn$delim2
if ([ "$day" = "01" ] && [[ "$minute" < "29" ]]) || [ ! -f $dird$last ]; then
echo >$dird$last $message
else
sed -i '1i'$message $dird$last
fi
echo $delim1$sourn$delim2
# rename the old file
cp $dest.$ext $dest'_back.'$ext
# copy the file
cat "$sour" >$dest.$ext
echo File copied as $delim1$dest.$ext$delim2
Can you please help me to understand why this happens, and how to fix it? Thank you very much for your attention!
find /storage/7BC3-1805/Music/MP3/Abba -type f -name *.mp3
--- it returns two strings containing the names of files inside that folder, but putting it in my script continues to return an empty array, so the issue is not in the access to the folder, but in the syntax, I guess (the code find is inside backticks) so it is as: echo <BT>find.... *.mp3<BT>