Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Can I create a new folder with Js in ID?

Community Beginner ,
Apr 03, 2008 Apr 03, 2008
Hi,

I want to create a new folder(not an exist folder) with JS in ID.

Anyone can tell me how to do?

Best Regards
Goldbridge
TOPICS
Scripting
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 03, 2008 Apr 03, 2008
Hi Goldbridge,

myFolder = new Folder ("~/Desktop/Images");
if (myFolder.exists == false){
myFolder.create();
}

Kasyan
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 04, 2008 Apr 04, 2008
Hi,Kasyan

Thanks a bunch.It does work well.

Now,I want to copy f1 to f2,but it doesn't work,can you tell me why?
/*****************/
f1=new File("~/Desktop/Images/1.txt");
f2=new Folder("~/Desktop/Images/aaa");
f1.copy(f2);
/*****************/

Best Regards
Goldbridge
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 04, 2008 Apr 04, 2008
Goldbridge,
I don't have time to check it, but f2, I think, should be a file path or a file object - not a folder object:

fileObj.copy (target)
target - A string with the URI path to the target location, or a File object that references
the target location.
Copies this objects referenced file to the specified target location. Resolves any aliases to find the source file. If a file exists at the target location, it is overwritten.

So it should be:

var myText = "save this";
f1=new File("~/Desktop/images/1.txt");
f1.open("w");
f1.write(myText);
f1.close();
// I assume that aaa folder already exists
f2=new Folder("~/Desktop/images/aaa");
f1.copy("~/Desktop/Images/aaa/1.txt");

Kasyan
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 06, 2008 Apr 06, 2008
LATEST
Hi,Kasyan

It does work very well,thanks a lot!

Best Regards
Goldbridge
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines