Was a way from someone else how to do this, but it did not work as it was dated and not made on another distribution.

DELETE_GCODES.sh

#!/bin/bash 
rm /home/pi/printer_data/gcodes/*
rm -r /home/pi/printer_data/gcodes/.*
echo Gcode Directory Emptied

k

USB_UNMOUNT-sh.sh

#!/bin/bash
for usb_device in /dev/sd[a-z][0-9]*; do
device_name=$(basename "$usb_device")
udisksctl unmount -b "$usb_device"
done

USB_MOUNT.sh

#!/bin/bash
for usb_device in /dev/sd[a-z][0-9]*; do
device_name=$(basename "$usb_device")
echo raspberry | sudo -S udisksctl mount -b "$usb_device"
done

USB_MOUNT.sh

#!/bin/bash
for usb_device in /dev/sd[a-z][0-9]*; do
device_name=$(basename "$usb_device")
echo raspberry | sudo -S udisksctl mount -b "$usb_device"
done

USB_KEY.sh

#!/bin/bash 
sudo fdisk -l | grep -oE '/dev/sd[a-z][0-9]+'

USB_COPY.sh

#!/bin/bash
destination_folder="/home/pi/printer_data/gcodes"
gcodes_folder="/media/root"
find "$gcodes_folder" -name \*.gcode -not -type d -execdir cp "{}" "$destination_folder" ";"
chown -R pi:pi /home/pi/printer_data/gcodes/

USB_Check.sh

#!/bin/bash 
ls /dev/serial/by-id/*

In shell_commands.cfg add.

[gcode_macro USB_KEY]
gcode:
    RUN_SHELL_COMMAND CMD=USB_KEY
[gcode_shell_command USB_KEY]
command: sudo /home/pi/printer_data/config/scripts/USB_KEY.sh
timeout: 2.
verbose: True

[gcode_macro USB_MOUNT]
gcode:
    RUN_SHELL_COMMAND CMD=USB_MOUNT
[gcode_shell_command USB_MOUNT]
command: /home/pi/printer_data/config/scripts/USB_MOUNT.sh
timeout: 2.
verbose: True

[gcode_macro USB_UNMOUNT]
gcode:
    RUN_SHELL_COMMAND CMD=USB_UNMOUNT
[gcode_shell_command USB_UNMOUNT]
command: sudo /home/pi/printer_data/config/scripts/USB_UNMOUNT.sh
timeout: 2.
verbose: True

[gcode_macro USB_COPY_GCODES]
gcode:
    RUN_SHELL_COMMAND CMD=USB_COPY_GCODES
[gcode_shell_command USB_COPY_GCODES]
command: sudo /home/pi/printer_data/config/scripts/USB_COPY.sh
timeout: 2.
verbose: True

[gcode_macro DELETE_GCODES]
gcode:
    RUN_SHELL_COMMAND CMD=DELETE_GCODES
[gcode_shell_command DELETE_GCODES]
command: /home/pi/printer_data/config/scripts/DELETE_GCODES.sh
timeout: 2.
verbose: True

You will need to add chmod 0777 to /media/root for everything to work. This is above all WIP that is tossed together to just work, i will more than anything have forgotten some necessary step to reproduce this.

Source - https://travis90x.altervista.org/klipper-usb-automount-copy-gcodes-in-home-pi-printer_data-gcodes-raspberry-armbian-tvbox/