Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)
Quote - Is it possible to have a python script that would remove any and all files within a Runtime folder structure?
Like anything withing DarkEdge:Simon:ThisFile
Is there a particular reason why you want a script for this ?
As it seems likely that you'd have to browse to the directory you cleared, why not just delete it via Explorer.
If you just want to be able to delete a directory tree by specifying a (full or relative to some location) path, then a simple BAT file would seem more appropriate.
Yes it is possible using python. If you can specify exactly what gets deleted.
The python command is a combination of walk , which lists a directory tree but you have to do deletes from the bottom up if you are deleting folders too. Its also not something you can get wrong , a mistake is very very bad .
If its just files though you can also do that from the cmd prompt using the old commands like dir and kill.
Well, I wanted to delete some files within the Runtime structure, they would be specifically within my own folders within that structure though. Understand?
Could that be done without botching the rest of the Runtime folders/files?
Example: Runtime:Geometries:DarkEdge:Simon:ThisFolder:ThisFile.obj
Comitted to excellence through art.
If you wanted to delete all contents of say "Simon" folder and everything below it in the tree that can be done by script. It would be almost as fast to use windows explorer and do it manually unless you need to do it very often , like a test installation.
The script would need to specify an exact file or folder name to delete .
Quote -
The python command is a combination of walk , which lists a directory tree but you have to do deletes from the bottom up if you are deleting folders too. Its also not something you can get wrong , a mistake is very very bad .
Sorry, no. You need just:
**
import os
os.removedirs()**
This will delete the path and files/subdirectories in the path.
This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.
Is it possible to have a python script that would remove any and all files within a Runtime folder structure?
Like anything withing DarkEdge:Simon:ThisFile
Thanks
Comitted to excellence through art.