how to perform copy file using imacros

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

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
bumusic
Posts: 36
Joined: Sun Nov 08, 2009 9:59 pm

how to perform copy file using imacros

Post by bumusic » Sun Oct 30, 2011 7:18 am

1. how to perform copy file using imacros

eg click "play" button

folder C:\zzz
file A.txt copies and rename to file B.txt

2. after I extracted text to txt file, it showed
"100"
"234"

how can i remove the quotation mark automatically? i mean i don't want the quotation mark.

i know you have FILEDELETE, do u also FILEDCOPY something like that?
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Re: how to perform copy file using imacros

Post by Tech Support » Sun Oct 30, 2011 11:39 am

iMacros itself has no copy command, but please see this solution: http://wiki.imacros.net/Web_Testing#Q:_ ... iMacros.3F
bumusic
Posts: 36
Joined: Sun Nov 08, 2009 9:59 pm

Re: how to perform copy file using imacros

Post by bumusic » Mon Oct 31, 2011 5:44 am

Tech Support wrote:iMacros itself has no copy command, but please see this solution: http://wiki.imacros.net/Web_Testing#Q:_ ... iMacros.3F

Code: Select all

Set objshell = CreateObject("Wscript.shell");
objshell.Run "cmd /c copy C:\text.txt C:\777.txt";
i ran "copy C:\text.txt C:\777.txt" on command prompt, it did copy

in js file,

iErrorCode = objShell.Run("ping http://www.mywebsite.com",,True)
the quotation mark make it a comment?

something like this?
iErrorCode = objShell.Run(copy C:\test.txt C:\777.txt)

even the sample code doesnt work :mrgreen:
SyntaxError: missing ; before statement (Error code: 991)
Tom, Tech Support
Posts: 3834
Joined: Mon May 31, 2010 4:59 pm

Re: how to perform copy file using imacros

Post by Tom, Tech Support » Mon Oct 31, 2011 11:06 am

bumusic,

The sample code is VBScript and requires the iMacros Scripting Edition. You can not use that code inside an iMacros for Firefox .js file.
Regards,

Tom, iMacros Support
bumusic
Posts: 36
Joined: Sun Nov 08, 2009 9:59 pm

Re: how to perform copy file using imacros

Post by bumusic » Tue Nov 01, 2011 8:39 pm

Tom, iOpus wrote:bumusic,

The sample code is VBScript and requires the iMacros Scripting Edition. You can not use that code inside an iMacros for Firefox .js file.
so how can we remove the double quotation mark when save to text ?

"aaa"
"bbb"
"ccc"

to

aaa
bbb
ccc

or replace the " file after saving
ie
"aaa"
"bbb"
"ccc"

and run code to become this

aaa"
"bbb"
"ccc"













/
bumusic
Posts: 36
Joined: Sun Nov 08, 2009 9:59 pm

Re: how to perform copy file using imacros

Post by bumusic » Wed Nov 02, 2011 7:32 am

Tom, iOpus wrote:bumusic,

The sample code is VBScript and requires the iMacros Scripting Edition. You can not use that code inside an iMacros for Firefox .js file.
i just solved it by the following:

1. create a bat file

Code: Select all

@echo off
copy /Y C:\test.txt C:\test2.txt
2. in imacros .js file, put this

Code: Select all

var file = Components.classes["@mozilla.org/file/local;1"]  
                     .createInstance(Components.interfaces.nsILocalFile);  
file.initWithPath("c:\\d.bat");  
file.launch(); 
test.txt, d.bat in C:\.............doubling click js file

now i can bookmark the js file and make COPY function with one click!!!
Last edited by bumusic on Wed Nov 02, 2011 7:03 pm, edited 1 time in total.
Tom, Tech Support
Posts: 3834
Joined: Mon May 31, 2010 4:59 pm

Re: how to perform copy file using imacros

Post by Tom, Tech Support » Wed Nov 02, 2011 6:03 pm

Excellent! Thanks for sharing your solution!
Regards,

Tom, iMacros Support
ravi_npatty
Posts: 22
Joined: Sat May 07, 2011 6:12 am

Re: how to perform copy file using imacros

Post by ravi_npatty » Sun Oct 28, 2012 2:14 pm

More simple solution would be

Code: Select all

function file_copy(from,to)
{
	var to_folder=to.substring(0,to.lastIndexOf("/")+1);
	var to_file=to.substring(to.lastIndexOf("/")+1);
	var source = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);	
	source.initWithPath(from);
	var target = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);	
	target.initWithPath(to_folder);	
	source.copyTo(target,to_file);	
 }
This will work in Linux. For Windows you need to change the path separator.
kostos
Posts: 2
Joined: Wed Sep 21, 2016 4:09 pm

Re: how to perform copy file using imacros

Post by kostos » Wed Sep 21, 2016 4:29 pm

as ONPRINT isn't supported with iMacros for Firefox found really simple solution for both onprint lack and copying files:
first print to pdf without prompt for filename to defaultFolder/default.pdf with Adobe PDF printer or similar,
then we can copy default.pdf with

Code: Select all

URL GOTO=file:///C:/defaultFolder/
ONDOWNLOAD FOLDER=C:\defaultFolder FILE=anyOtherFileName.pdf WAIT=YES
TAG POS=1 TYPE=A ATTR=TXT:default.pdf
Post Reply