Any one has a solution Pre/Post during switches Upgrade to clean up unnecessary package to free the space in flash memory. this is require to clean flash space in most 9k IOS-XE duo to the flash limitation. currently i do this step manually because no default action for this command. I have to press y in the right time, otherwise didn't take affect. Also if you manage large number of switches this is painful process (Not Automation task at all).
Actually if you intend to perform the upgrade using DNAC then you must not worry about this. DNAC has a feature called "Flash check"
"As a part of the auto flash cleanup, Cisco DNA Center identifies unused .bin, .pkg, and .conf files and delete them iteratively until enough free space is created on the device. Image distribution is attempted after the flash cleanup. You can view these deleted files in Sytem > Audit Logs."