Creating/using/deleting a con folder in Processing

Dear ladies and gentlepeople,
I’m using Processing in Java Mode, and my question is about to create a con folder in Processing.
I’ve used this technique in Batch before, using the commands in cmd.exe, you can see the con folder in your desktop:

cd userprofile\Desktop
rem To create a con folder:
md con
rem To create a txt file inside the con folder
echo.this is a test>“con\test.txt”
rem To remove the con folder:
rd con\

(you can paste this in notepad and save it as any name.bat and it run it via the computer by yourself, the idea behind this is that it is proven possible to create a con folder in Windows).
NOTE: don’t blame me it doesn’t work if you are a non-windows-user, because Linux and Mac don’t have Windows command prompt.

I tried this in Processing Java Mode:

String name=“con\”
void setup(){
savePath(name);
save(name+“/XD.png”);
}

and it doesn’t work.
Could anyone tell me how I can make a con file using Processing?
Thanks in advance.
Kind regards,
Duckhater

wait how do you use the </> for code?

btw this is wrong, image

// create an abstract pathname (File object)

File f = new File( "F:\\program" );

// check if the directory can be created

// using the abstract path name

if (f.mkdir()) {

// display that the directory is created

// as the function returned true

System.out.println( "Directory is created" );

}

else {

// display that the directory cannot be created

// as the function returned false

System.out.println( "Directory cannot be created" );

}

}

1 Like

Thank you for your reaction. I tried your code but it’s saying that the folder cannot be created.

I will demonstrate you how it works in cmd in images. They are placed in the right sequence, to prove it can be created. (my personal information is censored i hope)
No folder called “con” is on my desktop.


A folder called “con” has been created.

The file “text.txt” has been made inside the “non-existing” folder called “con”.

The “test.txt” file has been removed.

The con folder has been removed.

And the translation of

“Het bestand C:\Users<your username>\Desktop\con\test.txt is verwijderd”

means that file has been removed.

Is there any other way I can do it in Java? If not, could you show me, how I can import cmd.exe inside Processing?
Thanks in advance.
Duckhater.

workaround

works with con1, not con

String mySketchPath = sketchPath(""); 

save(mySketchPath +"//data//test.jpg");
save(dataPath("") 
  + "//con1//test.jpg");

So, it is interesting

Maybe in my first post try con1 instead of con

Maybe an old security thing of java

Thanks for your reaction again.
The purpose of creating a con file is to prohibit the user with little knowledge of coding to delete/edit the files with my project data in it by him/herself, manually, without coding.
With a little bit of base64 inside it (which I already have figured out), the user with no knowledge would probably think that’s because of the weird name of the folder.
Also, he can’t open it except in Notepad++ or by coding into it.

After all, I have considered RSA, an exaggerating, but idk how to find a prime number of 100 numbers.
But it’s not necessary if my project is dedicated to my classmates, who don’t know any of coding (yet?).

Here a link of the purpose of the con file: https://superuser.com/questions/86999/why-cant-i-name-a-folder-or-file-con-in-windows

If there is no solution without importing cmd.exe, is it actually possible to have cmd.exe in Processing? Like python mode in processing?

I don’t know

See https://processing.org/reference/launch_.html