Deleting files from your hard drive?

yns's icon

Is it possible to delete files from your hard drive with Max?

I am saving a couple of audio files and a text file in my patch and I would like to delete those files when the patch gets closed. I'm on OSX.

I know a little bit Java so maybe I could find a solution there (creating a mxj object for te problem)?

Any help would be nice.

EMV's icon
yns's icon

Thanks but if it is possible I would like to solve it without externals. Unless it would be something I program myself in Java.

Also I'm using Max 5.

pdelges's icon

Here is a small JAva class:

p

yns's icon

Thanks alot!

Can I conclude from this that with the native Max objects there is no solution for the problem?

pdelges's icon

I'm afraid there isn't. But that's why Java is included in Max.

The shell option is also valid, but it's not portable on MSWin.

p

yns's icon

And with the "shell option" you mean the external posted above?

pdelges's icon

I mean EMV's solution. shell doesn't exist on MSWin, although there is some kind of equivalent object (DOSHack). But if you need portability, then you 'll have to check in what environment you are, and then instantiate the right object thru scripting, etc. It's a real PITA.

p

yns's icon

Thanks for the explanation.

Do you maybe know a way to get the files you delete into OSX's Trash instead of hard deleting them from the Hard Drive?

pdelges's icon

On OSX, you should move the file to ~/.Trash

Here again, we are loosing portability...

Max Patch
Copy patch and select New From Clipboard in Max.

It can be done with my Java class but will need some tweaking:

yns's icon

Thanks for your quick reply. I don't care much about windows so no problems there.

seejayjames's icon

Out of curiosity, can this be done with javascript too?

pdelges's icon

I don't think so!