imacros javascript - creating new folder

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
Juliensohn
Posts: 6
Joined: Sat Sep 27, 2014 5:07 am

imacros javascript - creating new folder

Post by Juliensohn » Sat Oct 25, 2014 8:30 pm

Hey, I want to create a new folder in a the download direction of imacros (C:\\Users\\Besitzer\\Documents\\iMacros\\Downloads\\)
I have the name of the folder saved in a variable.. let's say the variable is called foldername

How to create a new folder in this direction and name it as the content of 'foldername'?
Do you know what I mean?

Anyone a solution? :D


Sorry for bad english. ._.
User avatar
thecoder2012
Posts: 359
Joined: Sat Aug 15, 2015 5:14 pm
Location: Internet
Contact:

Re: imacros javascript - creating new folder

Post by thecoder2012 » Wed Oct 02, 2019 10:42 am

Juliensohn wrote:
Sat Oct 25, 2014 8:30 pm
Hey, I want to create a new folder in a the download direction of imacros (C:\\Users\\Besitzer\\Documents\\iMacros\\Downloads\\)
I have the name of the folder saved in a variable.. let's say the variable is called foldername

How to create a new folder in this direction and name it as the content of 'foldername'?
Do you know what I mean?

Anyone a solution? :D
With JavaScript, yes.

1. First way

Code: Select all

var foldername = "newfolder";
imns.FIO.makeDirectory(imns.Pref.getFilePref('defdownpath').path+"\\"+foldername);
2. Second way

Code: Select all

var foldername = "newfolder";

var file = Components.classes["@mozilla.org/file/local;1"].
           createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(imns.Pref.getFilePref('defdownpath').path);
file.append(foldername);
file.create(1,0600);//0=File,1=Directory
https://developer.mozilla.org/en-US/doc ... e#create()
https://developer.mozilla.org/en-US/doc ... s/File_I_O
https://developer.mozilla.org/en-US/doc ... eUtils.jsm

Tested with Win8.1 (64-Bit), Basilisk 2019.09.21 (64-Bit) and iMacros 8.9.7
With Waterfox 56.2.14 (or firefox legacy version 56) you can set in about:config this field "dom.ipc.cpows.forbid-unsafe-from-browser" to false If you have "CPOW usage forbidden" as error.
Join 9kw.eu Captcha Service now and let your iMacros continue downloads and scripts while you sleep. - Custom iMacros? Contact me! :idea:
chivracq
Posts: 8719
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: imacros javascript - creating new folder

Post by chivracq » Wed Oct 02, 2019 2:18 pm

Juliensohn wrote:
Sat Oct 25, 2014 8:30 pm
Hey, I want to create a new folder in a the download direction of imacros (C:\\Users\\Besitzer\\Documents\\iMacros\\Downloads\\)
I have the name of the folder saved in a variable.. let's say the variable is called foldername

How to create a new folder in this direction and name it as the content of 'foldername'?
Do you know what I mean?

Anyone a solution? :D

Sorry for bad english. ._.
thecoder2012 wrote:
Wed Oct 02, 2019 10:42 am
Juliensohn wrote:
Sat Oct 25, 2014 8:30 pm
Hey, I want to create a new folder in a the download direction of imacros (C:\\Users\\Besitzer\\Documents\\iMacros\\Downloads\\)
I have the name of the folder saved in a variable.. let's say the variable is called foldername

How to create a new folder in this direction and name it as the content of 'foldername'?
Do you know what I mean?

Anyone a solution? :D
With JavaScript, yes.

1. First way

Code: Select all

var foldername = "newfolder";
imns.FIO.makeDirectory(imns.Pref.getFilePref('defdownpath').path+"\\"+foldername);
2. Second way

Code: Select all

var foldername = "newfolder";

var file = Components.classes["@mozilla.org/file/local;1"].
           createInstance(Components.interfaces.nsILocalFile);
file.initWithPath(imns.Pref.getFilePref('defdownpath').path);
file.append(foldername);
file.create(1,0600);//0=File,1=Directory
https://developer.mozilla.org/en-US/doc ... e#create()
https://developer.mozilla.org/en-US/doc ... s/File_I_O
https://developer.mozilla.org/en-US/doc ... eUtils.jsm

Tested with Win8.1 (64-Bit), Basilisk 2019.09.21 (64-Bit) and iMacros 8.9.7
With Waterfox 56.2.14 (or firefox legacy version 56) you can set in about:config this field "dom.ipc.cpows.forbid-unsafe-from-browser" to false If you have "CPOW usage forbidden" as error.

Yeah, nice, @thecoder2012, but it can also easily be done in pure '.iim' as that Functionality is already implemented in the 'FOLDER' Param for the 'ONDOWNLOAD' Command (and 'SAVEAS' also, I think), so your Solutions look a bit "cumbersome" to me... :idea:
But nice and "interesting" Syntax anyway, Thanks for sharing... :D

You could have waited for another 3 weeks, to bump this Thread exactly on its 5-year Anniversary, ah-ah...! :wink:

(I never answered this Thread because @OP had not mentioned their FCI, while I had already asked them in some previous Thread, and they never followed up in their 2 previous Threads (1 and 2), so I stopped answering their Threads... :roll: )
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
User avatar
thecoder2012
Posts: 359
Joined: Sat Aug 15, 2015 5:14 pm
Location: Internet
Contact:

Re: imacros javascript - creating new folder

Post by thecoder2012 » Thu Oct 03, 2019 11:11 am

chivracq wrote:
Wed Oct 02, 2019 2:18 pm
Yeah, nice, @thecoder2012, but it can also easily be done in pure '.iim' as that Functionality is already implemented in the 'FOLDER' Param for the 'ONDOWNLOAD' Command (and 'SAVEAS' also, I think), so your Solutions look a bit "cumbersome" to me... :idea:
The title was "imacros javascript - creating new folder" and nothing in pure iim. :wink:
chivracq wrote:
Wed Oct 02, 2019 2:18 pm
You could have waited for another 3 weeks, to bump this Thread exactly on its 5-year Anniversary, ah-ah...! :wink:
3 weeks is too long. Todolist is already full. :shock:
chivracq wrote:
Wed Oct 02, 2019 2:18 pm
(I never answered this Thread because @OP had not mentioned their FCI, while I had already asked them in some previous Thread, and they never followed up in their 2 previous Threads (1 and 2), so I stopped answering their Threads... :roll: )
I understand your reasons but for other users and as archive not helpful in this case and in my opinion. But very good because your answer was with links! :)
Join 9kw.eu Captcha Service now and let your iMacros continue downloads and scripts while you sleep. - Custom iMacros? Contact me! :idea:
Post Reply