Not All Files are Uploaded

This is my process:
RuTorrent downloads to a folder, then unzips and then moves to the RCLONE monitored folder to be processed to my GDrive.

I am getting duplicate folders and I am also getting only the zipped files not the actual file from the zipped (mkv).

This is some info in my CRON file where I made a few changes:

if find $FROM* -type f -mmin +15 | read
then
start=$(date +’%s’)
echo “$(date “+%d.%m.%Y %T”) RCLONE UPLOAD STARTED” | tee -a $LOGFILE

MOVE FILES OLDER THAN 15 MINUTES

rclone move “$FROM” “$TO” --transfers=20 --checkers=20 --min-age 15m –delete-empty-src-dirs --log-file=$LOGFILE
echo “$(date “+%d.%m.%Y %T”) RCLONE UPLOAD FINISHED IN $(($(date +’%s’) - $start)) SECONDS”$ | tee -a $LOGFILE
fi
exit

I added –delete-empty-src-dirs and that is when I started seeing duplicates.

I really wanted the “delete” flag to work.

So now I changed it back to the way it was before and everything works fine except I have to manually go in and delete the empty folders:

rclone move “$FROM” “$TO” --transfers=20 --checkers=20 --delete-after --min-age 15m --log-file=$LOGFILE
echo “$(date “+%d.%m.%Y %T”) RCLONE UPLOAD FINISHED IN $(($(date +’%s’) - $start)) SECONDS” | tee -a $LOGFILE

Yeah, that –delete-empty-src-dirs does not work like you think. (Or maybe it is bugged idk)

But I had problems with it too and read some other people had trouble as well. I assume it is the way rclone iterates over folders and in that process it can not delete empty folders. For unknown reasons.

So I have wrote a little python script that just checks after rclone has uploaded/moved every file to your cloud.

os.chdir('/home/downloads/')  # current work directory
print('[+] deleting empty directories.')
os.system("find . -type d -empty -delete")

I had never any problems again and all is cleaned up after every upload. Even if rclone fails to upload everything, because of a crash or something. The script only delete empty folders.

PS: my os is a Linux Suse with python3, but this should work on mostly any system. Even for windows should be a similar command with the powershell.