# Using open() in processing 2

**URL:** <https://discourse.processing.org/t/using-open-in-processing-2/7606>\
**Category:** Coding Questions\
**Created:** [January 17, 2019, 10:00pm UTC](https://discourse.processing.org/t/using-open-in-processing-2/7606 "2019-01-17T22:00:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeffmarc](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jeffmarc](https://discourse.processing.org/u/jeffmarc)\
**Post date:** [January 17, 2019, 10:00pm UTC](https://discourse.processing.org/t/using-open-in-processing-2/7606/1 "2019-01-17T22:00:56Z")

</div>

I know launch is the new open in 3.0+  
but I use open to run .exe 's and everything works fine.

I want to rename a file using open and the cmd .exe  
i tried:

> open(“rename c:\path\file.fil file.bak”)

and nothing happens , no error but .bak fil is not created  
same line at command prompt works fine , so syntax is correct.

Also tryed putting cmd.exe before rename , same result.

Should be able to invoke command sthe same as command line right?  
Am I missing something in the syntax for open to work?

Thanks

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [January 21, 2019, 7:16pm UTC](https://discourse.processing.org/t/using-open-in-processing-2/7606/2 "2019-01-21T19:16:40Z")

</div>

I thought that `launch` and `exec` were both present in both 2.0 and 3.0 – and only `launch` was listed on the reference, but both are in the API.

I’m not as familiar with the Windows command line – I can only test on Linux / Mac, so I can’t answer your question.

You might want to try `exec`, which is mentioned in the launch reference and described in the API linked from the top of each reference page.

- [Processing Java API: PApplet.exec](http://processing.github.io/processing-javadocs/core/processing/core/PApplet.html#exec-java.lang.String...-)

---

<div class="post-metadata">

**Author:** ![jeffmarc](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jeffmarc](https://discourse.processing.org/u/jeffmarc)\
**Post date:** [January 21, 2019, 11:43pm UTC](https://discourse.processing.org/t/using-open-in-processing-2/7606/3 "2019-01-21T23:43:59Z")

</div>

Thanks for your reply.  
I tryed exec and launch and both give not recognized error  
i’m using 2.2.1

Will do it again in smaller context test sketch to make sure.  
thanks  
Jeff

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [January 22, 2019, 1:32am UTC](https://discourse.processing.org/t/using-open-in-processing-2/7606/4 "2019-01-22T01:32:57Z")

</div>

Apologies if I was wrong about `exec()` – I don’t have Processing 2.2.1 on this machine for a quick check. Could download and check the reference folder for the API files.

If the object to be renamed is static, a workaround might be to open a script (e.g. a bat file) referenced by static name, and put your rename command and argument in that file. Use open on the bat. Untested as I am not on Windows.

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [January 22, 2019, 6:19am UTC](https://discourse.processing.org/t/using-open-in-processing-2/7606/5 "2019-01-22T06:19:13Z")

</div>

> [@jeffmarc](#):
>
> I want to rename a file using **open()** and the “cmd.exe”.

[Docs.Oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html#renameTo(java.io.File)](http://Docs.Oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html#renameTo(java.io.File))
