Purge Upload Folder


I am heading towards running out of free space in my upload folder.
I am running a tiny print-farm and found convenient to send all of my g-code files to all of my printers thru watched folder, then choose which one prints which files. Thus hundreds of files uploaded, not all of them printed and not all of them successfully.

My goal is to clean up the folder once in a while to re-upload what is outstanding to be printed.
Clicking a delete button in the UI is painful and almost impossible at this point.
Assuming that the upload folder is being indexed somehow, what is the proper way to delete all the files in the upload folder?

maybe I could set-up Samba permissions to these folders, map them to my PC like I did with watched folder?
maybe someone could write a handy wizard plugin?
maybe there is an event command which could do it from within the UI of octoprint.

any advises are welcome, with as much info as the newbee needs.

Thanks to everyone in advance


make a system command that executes rm -rf /home/pi/.octoprint/uploads/* in the system menu, call it "Purge Uploads", whack a tick in that confirmation box and you're laughing.

I used the system command editor to make adding it easier (and the confirmation check box probably only makes sense if you are using this plugin): System Command Editor


or you setup a custom gcode for it and add it at the end if each gcode file with your slicer


Thanks, it looks like exactly what I need, will try it tonight, and post progress


any example? how could g-code interact with octoprint system?


sshing in and deleting the files is probably the easiest. If you want, we can give you a command that will delete files uploaded more than N days ago.


This sounds like another cool solution, could you please write up more? Although sometimes these batches of prints go by the hours, and sometimes by weeks.


Here's how to find older files (older than 14 days):

find /home/pi/.octoprint/uploads/ -mtime +14 -type f -not -name "*.yaml"

add -delete to nuke them:

find /home/pi/.octoprint/uploads/ -mtime +14 -type f -not -name "*.yaml" -delete

If it returns nothing you're good. Otherwise it'll print any errors. Obviously, change '14' to whatever you want.


Thanks! Good to know that this is possible. maybe would find a need to impement something like this at some other need. so it stays untested by me at this point. also ssh into every machine of the farm sounds like a lot of one to one attention.


What did I miss?
Restarted the server, and it still doesn't execute


Look in the logs to see what's failing with that.

You could put the find in a cron, or use ansible to run it across a farm. Not a beginner topic though.



Weird, I could have sworn that's what my purge command was. I'll see if it still works / whether that is what I had. I may have actually told octoprint to execute some sort of script in my home dir like "purge.sh" or something, with that command in it.

Will get back to you

edit: This command works for me
rm -rf /home/mint/.octoprint/uploads/* ; rm /home/mint/.octoprint/uploads/.metadata.yaml
Obvoiusly my user name is mint and not pi. Just removing * doesn't seem to remove the metadata file so I added that in to specifically remove it too.



rm -rf /home/pi/.octoprint/uploads/* ; rm /home/pi/.octoprint/uploads/.metadata.yaml
doesnt work, and this is the only line in the log:
2018-04-12 10:56:19,823 - tornado.access - WARNING - 404 POST /api/system/commands/custom/ ( 54.33ms
octoprint.log (90.9 KB)


That's really weird, I'm using it on a custom install so maybe my permissions are slightly different. I'll see if I can dig up a spare SD card and install octopi on it and see if it still works there (maybe of note, I've usually always used a custom install so perhaps something is slightly different to my environment).


Assuming you have set up a keypair so you can ssh in without a password:

rsync -av --remove-source-files --exclude **/tmp/ pi@octopi3:/home/pi/.octoprint/timelapse/* /home/user/video/printercam/


FYI, I am using PrusaPrint image of octoprint:
Download here:


Just downloaded the prusa print version and it works just fine for me. Make sure you fill out all the fields in the system command editor to match what I have. I noticed you have no "action" and nothing for the message, try filling those out.


I guess it was indeed filling all the fields.

Thank you All!