Deleting cached files directly?

   3750   13   0
User Avatar
Member
208 posts
Joined: May 2021
Offline
In order to delete the cache files in bgeo.sc format, I have to manually go to the folder in file explorer and then delete all the files there. Is there a direct way in Houdini that allows me to clear those files directly from node tree?
Edited by proceduralist - Nov. 10, 2022 11:56:22
User Avatar
Member
8173 posts
Joined: Sept. 2011
Offline
you could use a shell rop to run the rm command
User Avatar
Member
208 posts
Joined: May 2021
Offline
jsmack
you could use a shell rop to run the rm command
How do I use shell rop to run rm command to delete cache? Please share step by step method.
Edited by proceduralist - Nov. 10, 2022 12:55:56
User Avatar
Member
313 posts
Joined: Oct. 2016
Offline
Hi, I’ll try to help but am on the move.

There should be some ”shell ROP” node (never used it).

It should sent standard OS commands to the system. If you have Windows as OS you can search for the basic command to delete all files in a given folder. Do this carefully.

If you are using Linux the command is ”rm -rf /tmp/my_cache_folder/*.sc” or whatever you use.

Edit: Since Python is suitable for those manual things I would use that, but it require more learning.

Your user must have write permission to that folder.
Edited by SWest - Nov. 13, 2022 03:22:30
Interested in character concepts, modeling, rigging, and animation. Related tool dev with Py and VEX.
User Avatar
Member
208 posts
Joined: May 2021
Offline
Okay I used this node for the first time but I'm using windows. I don't know what to type for deleting cached files.


I searched here but found nothing.
https://www.sidefx.com/docs/houdini/nodes/out/shell.html [www.sidefx.com]
User Avatar
Member
9325 posts
Joined: July 2007
Online
you can use TOPs
FilePattern TOP + Remove File TOP (Source/File: Upstream Output Files)

just be careful
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
313 posts
Joined: Oct. 2016
Offline
Sorry, I do not know anything about TOP:s (as Tamte mentioned), except I saw there is a filedelete node.

So I just searched for first best Python snippet for Windows.

import os, subprocess
del_dir = r'c:\windows\temp'
pObj = subprocess.Popen('del /S /Q /F %s\\*.*' % del_dir, shell=True, stdout = subprocess.PIPE, stderr= subprocess.PIPE)
rTup = pObj.communicate()
rCod = pObj.returncode
if rCod == 0:
    print 'Success: Cleaned Windows Temp Folder'
else:
    print 'Fail: Unable to Clean Windows Temp Folder'

Your text to link here... [stackoverflow.com]


If you know how to get the path to your target folder and put that in a variable, then just replace the "del_dir" part in the snippet above you are probably done.

There are some more notes about this for Windows in the link.

Maybe someone who run Windows could test this out.


Edit: The idea is this. If you can get this snippet to work for you using relative path, then you could probably drag the entire node to your shelf or so. Then just drag it to whatever project you want and it should work.

Edit2: The windows "shell" command could be something like:
rmdir "C:\Users\username\Desktop\MyFolder"
However, I guess you need a relative path.

Probably I need a Windows VM or equivalent to give better support for this.
Edited by SWest - Nov. 13, 2022 03:27:20
Interested in character concepts, modeling, rigging, and animation. Related tool dev with Py and VEX.
User Avatar
Member
208 posts
Joined: May 2021
Offline
SWest
Sorry, I do not know anything about TOP:s (as Tamte mentioned), except I saw there is a filedelete node.

So I just searched for first best Python snippet for Windows.

import os, subprocess
del_dir = r'c:\windows\temp'
pObj = subprocess.Popen('del /S /Q /F %s\\*.*' % del_dir, shell=True, stdout = subprocess.PIPE, stderr= subprocess.PIPE)
rTup = pObj.communicate()
rCod = pObj.returncode
if rCod == 0:
    print 'Success: Cleaned Windows Temp Folder'
else:
    print 'Fail: Unable to Clean Windows Temp Folder'

Your text to link here... [stackoverflow.com]


If you know how to get the path to your target folder and put that in a variable, then just replace the "del_dir" part in the snippet above you are probably done.

There are some more notes about this for Windows in the link.

Maybe someone who run Windows could test this out.


Edit: The idea is this. If you can get this snippet to work for you using relative path, then you could probably drag the entire node to your shelf or so. Then just drag it to whatever project you want and it should work.

Edit2: The windows "shell" command could be something like:
rmdir "C:\Users\username\Desktop\MyFolder"
However, I guess you need a relative path.

Probably I need a Windows VM or equivalent to give better support for this.

I am totally confused. Where to I put this long line of code? There's no filedelete node available. I am using Houdini 19.5.430
Edited by proceduralist - Nov. 14, 2022 11:50:31
User Avatar
Member
208 posts
Joined: May 2021
Offline
tamte
you can use TOPs
FilePattern TOP + Remove File TOP (Source/File: Upstream Output Files)

just be careful

I have never used TOPS. I dropped this node for the first time ever in a Houdini file.



What should I do now?

P.S. Am I unknowingly moving towards a process which is more complex than just selecting all the bgeo files in Windows and deleting them manually?
User Avatar
Member
208 posts
Joined: May 2021
Offline
Bump...
User Avatar
Member
313 posts
Joined: Oct. 2016
Offline
Hi,

previously I could not focus on this issue, but now I developed something for you.

Please place the following code as a shelf button and then drag it into your network editor or scene.
Edited by SWest - Oct. 10, 2023 16:42:37

Attachments:
obj_subnet_delete_folder.py (12.4 KB)

Interested in character concepts, modeling, rigging, and animation. Related tool dev with Py and VEX.
User Avatar
Member
208 posts
Joined: May 2021
Offline
Thanks a lot for sharing this script. However, when I connect the file cache to the input, and press the delete button, I get the notificatoin that the files are gone. But the files still remain.

Edited by proceduralist - Oct. 11, 2023 06:43:57
User Avatar
Member
313 posts
Joined: Oct. 2016
Offline
Okay, the node expect you to set the Parm ”Delete Folder”.

You do not need to connect any inputs.

Cheers!

Edit: If it does not work in your case it is easy to fix when you provide clear feedback as you did now.
Edited by SWest - Oct. 11, 2023 07:52:19
Interested in character concepts, modeling, rigging, and animation. Related tool dev with Py and VEX.
User Avatar
Member
208 posts
Joined: May 2021
Offline
Thanks! It worked!
  • Quick Links