Create Folder with iMacros / JavaScript

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
yquant
Posts: 19
Joined: Tue Nov 16, 2010 10:00 am

Create Folder with iMacros / JavaScript

Post by yquant » Thu Jan 20, 2011 4:47 pm

Hey there,

I was wondering myself if iMacros can create folders or if there is a way to do this with JavaScript.

I want iMacros to automatically create a structure of folders where data about the running macro will be saved.

I tried to do it with:

SAVEAS TYPE=EXTRACT FOLDER={{PATH}}\{{FolderIwishToCreate}} FILE=blah.csv

But I get the following error:
RuntimeError: Path C:\... does not exist, line x

Now i thought, when there is a command FILEDELETE, why can't iMacros create new folders?
Tom, Tech Support
Posts: 3440
Joined: Mon May 31, 2010 4:59 pm

Re: Create Folder with iMacros / JavaScript

Post by Tom, Tech Support » Wed Jan 26, 2011 4:03 pm

Hi yquant,

As you already discovered, this functionality is not supported by iMacros for Firefox, you'll have to use Javascript.
Regards,

Tom, iMacros Support
admazy
Posts: 3
Joined: Thu Jan 15, 2015 6:03 pm

Re: Create Folder with iMacros / JavaScript

Post by admazy » Sat Jan 05, 2019 4:50 pm

Let me just leave it here, because I tried to find a solution for my script and found here this question.

ONDOWNLOAD FOLDER={{PATH}}\{{FolderIwishToCreate}} FILE=*
SAVEAS TYPE=EXTRACT FOLDER={{PATH}}\{{FolderIwishToCreate}} FILE=blah.csv

:D
chivracq
Posts: 8144
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Create Folder with iMacros / JavaScript

Post by chivracq » Sat Jan 05, 2019 6:50 pm

admazy wrote:
Sat Jan 05, 2019 4:50 pm
Let me just leave it here, because I tried to find a solution for my script and found here this question.

Code: Select all

ONDOWNLOAD FOLDER={{PATH}}\{{FolderIwishToCreate}} FILE=*
SAVEAS TYPE=EXTRACT FOLDER={{PATH}}\{{FolderIwishToCreate}} FILE=blah.csv
:D
Yep, Thanks for sharing, but the original Thread and OP was from 2011, some 8 years ago, and the 'Create Folder' Functionality got later (from around iMB v10.3 I think) implemented with the 'FOLDER' Parameter as part of the 'ONDOWNLOAD' and 'SAVEAS' Commands, like documented in the Wiki...:
Notes
FOLDER does not accept relative path, FILE does. In case you want to download to a subfolder under the iMacros downloads folder, you can use the FILE parameter, but that subfolder needs to exist prior to the download.
Just the FOLDER parameter creates folders, so if the folder is not there yet, it has to appear in FOLDER, not in FILE.
(The iMacros v10.0.x for CR/FF 'Free' Versions do not support this 'FOLDER' Parameter btw..., only the 'PE' Versions support it...)
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
admazy
Posts: 3
Joined: Thu Jan 15, 2015 6:03 pm

Re: Create Folder with iMacros / JavaScript

Post by admazy » Sat Jan 05, 2019 9:52 pm

chivracq wrote:
Sat Jan 05, 2019 6:50 pm
admazy wrote:
Sat Jan 05, 2019 4:50 pm
Let me just leave it here, because I tried to find a solution for my script and found here this question.

Code: Select all

ONDOWNLOAD FOLDER={{PATH}}\{{FolderIwishToCreate}} FILE=*
SAVEAS TYPE=EXTRACT FOLDER={{PATH}}\{{FolderIwishToCreate}} FILE=blah.csv
:D
Yep, Thanks for sharing, but the original Thread and OP was from 2011, some 8 years ago, and the 'Create Folder' Functionality got later (from around iMB v10.3 I think) implemented with the 'FOLDER' Parameter as part of the 'ONDOWNLOAD' and 'SAVEAS' Commands, like documented in the Wiki...:
Notes
FOLDER does not accept relative path, FILE does. In case you want to download to a subfolder under the iMacros downloads folder, you can use the FILE parameter, but that subfolder needs to exist prior to the download.
Just the FOLDER parameter creates folders, so if the folder is not there yet, it has to appear in FOLDER, not in FILE.
(The iMacros v10.0.x for CR/FF 'Free' Versions do not support this 'FOLDER' Parameter btw..., only the 'PE' Versions support it...)
1. I left this answer for someone who is trying to do a similar thing in 2019 and later.
2. Just checked this special for you on Win XP x32 + Firefox 3.1 Beta 3 + iMacros for Firefox 6.2.1.5 (it's almost 10 years ago) and it works.

Code: Select all

VERSION BUILD=6210326 RECORDER=FX
ONDOWNLOAD FOLDER=C:\\SOME_FOLDER FILE=*
chivracq
Posts: 8144
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Create Folder with iMacros / JavaScript

Post by chivracq » Sun Jan 06, 2019 10:23 am

admazy wrote:
Sat Jan 05, 2019 9:52 pm
1. I left this answer for someone who is trying to do a similar thing in 2019 and later.
2. Just checked this special for you on Win XP x32 + Firefox 3.1 Beta 3 + iMacros for Firefox 6.2.1.5 (it's almost 10 years ago) and it works.

Code: Select all

VERSION BUILD=6210326 RECORDER=FX
ONDOWNLOAD FOLDER=C:\\SOME_FOLDER FILE=*
Hum-hum, yep-yep-yep, you seem to be completely right...!, only the 'ONDOWNLOAD' Command is able to create the new Folder, it (still) doesn't work from the 'SAVEAS' Command (I tested using v8.8.2 + v8.9.7, both for FF), so I guess your Solution would have already worked indeed for OP, 9 years ago... 8)
(I'm impressed btw you maintain such an old FCI, ah-ah...! 8) )

Mini-Detail, '!ERRORIGNORE' would also be needed, even with a 'SAVEAS' after the 'ONDOWNLOAD', or some "ONDOWNLOAD command was used but no download occurred. (Error code: -804)" RuntimeError will occur later on if the Script is still running after '!TIMEOUT_DOWNLOAD' has been reached... :|

("Funny" thing is that the 'SET !ERRORIGNORE YES' can also be placed after the 'ONDOWNLOAD' Line, as long as that Line has been reached before the Timeout ran out, ah-ah...! "Interesting" Behaviour actually, that could be used for some Conditional Aborting of a Script, even if there are easier Methods... 8) )

>>>

And I notice btw a "Mistake" in the Wiki concerning '!TIMEOUT_DOWNLOAD':
This is by default equal to !TIMEOUT_PAGE [...]
=> This is not correct, at least both in v8.8.2 and v8.9.7, => the Default Value is '!TIMEOUT_PAGE'/2...
=> 30 Sec for example if Default (or set in the Script) '!TIMEOUT_PAGE' = 60 Sec.

>>>

... And now I can go and delete all those 8 separate Folders that got created from that Testing, ah-ah...! :shock:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
Tom, Tech Support
Posts: 3440
Joined: Mon May 31, 2010 4:59 pm

Re: Create Folder with iMacros / JavaScript

Post by Tom, Tech Support » Tue Jan 08, 2019 1:24 pm

chivracq wrote:
Sun Jan 06, 2019 10:23 am
And I notice btw a "Mistake" in the Wiki concerning '!TIMEOUT_DOWNLOAD':
This is by default equal to !TIMEOUT_PAGE [...]
=> This is not correct, at least both in v8.8.2 and v8.9.7, => the Default Value is '!TIMEOUT_PAGE'/2...
=> 30 Sec for example if Default (or set in the Script) '!TIMEOUT_PAGE' = 60 Sec.
This statement in the wiki regarding the default value of !TIMEOUT_DOWNLOAD applies specifically to the iMacros browser and iMacros for IE. In the current (v10.x) versions of iMacros for Chrome and Firefox, the default is 300 seconds. The !TIMEOUT_DOWNLOAD variable is not even supported in iMacros for Firefox 8.9.7.
Regards,

Tom, iMacros Support
chivracq
Posts: 8144
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Create Folder with iMacros / JavaScript

Post by chivracq » Tue Jan 08, 2019 1:54 pm

Tom, Tech Support wrote:
Tue Jan 08, 2019 1:24 pm
chivracq wrote:
Sun Jan 06, 2019 10:23 am
And I notice btw a "Mistake" in the Wiki concerning '!TIMEOUT_DOWNLOAD':
This is by default equal to !TIMEOUT_PAGE [...]
=> This is not correct, at least both in v8.8.2 and v8.9.7, => the Default Value is '!TIMEOUT_PAGE'/2...
=> 30 Sec for example if Default (or set in the Script) '!TIMEOUT_PAGE' = 60 Sec.
This statement in the wiki regarding the default value of !TIMEOUT_DOWNLOAD applies specifically to the iMacros browser and iMacros for IE. In the current (v10.x) versions of iMacros for Chrome and Firefox, the default is 300 seconds. The !TIMEOUT_DOWNLOAD variable is not even supported in iMacros for Firefox 8.9.7.
Ah OK, I actually didn't use at all that Var in my Testing, only the '!TIMEOUT_PAGE' Var and the 'ONDOWNLOAD' Command which does have (in v8.8.2 + v8.9.7) some "Default" "TIMEOUT_ONDOWNLOAD" Functionality then if I can call it like that which is exactly the Half (50%) of '!TIMEOUT_PAGE' in my Testing..., and can be controlled by setting '!TIMEOUT_PAGE'... 8)

Could be nice btw to mention/add in the Wiki (for 'SAVEAS') that only the 'FOLDER' Parameter from 'ONDOWNLOAD' is able to create a new Folder, I always took for granted that the same 'FOLDER' Parameter worked the same way in both Commands..., but apparently that's not the case... (well, at least until v8.9.7 for FF)... :idea:
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
Tom, Tech Support
Posts: 3440
Joined: Mon May 31, 2010 4:59 pm

Re: Create Folder with iMacros / JavaScript

Post by Tom, Tech Support » Tue Jan 08, 2019 7:10 pm

chivracq wrote:
Tue Jan 08, 2019 1:54 pm
Could be nice btw to mention/add in the Wiki (for 'SAVEAS') that only the 'FOLDER' Parameter from 'ONDOWNLOAD' is able to create a new Folder, I always took for granted that the same 'FOLDER' Parameter worked the same way in both Commands..., but apparently that's not the case... (well, at least until v8.9.7 for FF)... :idea:
Done. Actually, SAVEAS *does* create the folder when playing a macro in the iMacros browser or iMacros for IE. Additionally, the current versions of iMacros for Chrome and Firefox (v10.x) do not create the folder even for ONDOWNLOAD. I also added a new feature request to make these commands more consistent across browsers, if possible.
Regards,

Tom, iMacros Support
Post Reply