File size sorter script

A script which may be helpful if you need to sort a lot of files by size.

FileSize-sorter.zip

Code:


#!/bin/bash
##
## RJP 17.3.2024 file sorter by size. It may be helpful if you need to separete a lot of files within size. It is not perfect, but it works somehow.
## You can add k or M after digit to the size box. 1000 means 1k and 1000000 means 1M for example.
# You can copy files you want from /tmp/FILE/small and /tmp/FILE/small will disappear at the next boot
#
SIZE=`yad --center --width=500 --height=100 --text-align=center --text="Put file size and k or M for moving files" --entry --entry-label= --entry-text=""`
FILE=$(yad --center --width=500 --height=100 --file --multiple)
echo "$FILE" > /tmp/output
sed 's/|/ /g' /tmp/output > /tmp/files
sed "s/ /\n/g" /tmp/files > /tmp/files2
mkdir -p /tmp/FILE/small
sleep 1
cp $(cat /tmp/files2) /tmp/FILE
sleep 3
cd /tmp/FILE
sleep 1
echo "under $SIZE here" > size
find . -size -$SIZE -type f -exec mv {} small/ \;
sleep 1
xdg-open /tmp/FILE/small
exit