How to have a "filename" variable?

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
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
Loginbug
Posts: 9
Joined: Tue Feb 02, 2010 7:36 pm

How to have a "filename" variable?

Post by Loginbug » Thu Feb 11, 2010 11:32 am

Hi to all. Here is my simple script. This script is used for download a .torrent file from a webpage, then upload it on a another site. 8)

Code: Select all

VERSION BUILD=6500125 RECORDER=FX
TAB T=1
//Get the torrent file.
TAG POS=1 TYPE=A ATTR=TXT:*.torrent 
//Call it "new.torrent"
ONDOWNLOAD FOLDER=* FILE=new.torrent WAIT=YES
TAB OPEN
TAB T=2
//Go to another site.
URL GOTO=torrenteditor.com
FRAME F=0
//Upload "new.torrent"
TAG POS=1 TYPE=INPUT:FILE FORM=ACTION:edit.php?upload ATTR=NAME:torrentfile CONTENT=C:\Users\Administrator\Documents\iMacros\Downloads\new.torrent
In this way i lost the original filename. How can i have a "filename" variables for doing this?
Define: *.torrent --> "[filename variable]"

Code: Select all

//Upload "new.torrent"
TAG POS=1 TYPE=INPUT:FILE FORM=ACTION:edit.php?upload ATTR=NAME:torrentfile CONTENT=C:\Users\Administrator\Documents\iMacros\Downloads\"[filename variable]"
Thanks for help.
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: How to have a "filename" variable?

Post by Daniel, Tech Support » Fri Feb 12, 2010 1:16 am

Hello,

You're actually setting the file name to "new.torrent" in your code. If you want to preserve the original file name, you should use FILE=* instead.
Please see this wiki article for more info.

Best regards,
Daniel, iOpus Support
Loginbug
Posts: 9
Joined: Tue Feb 02, 2010 7:36 pm

Re: How to have a "filename" variable?

Post by Loginbug » Fri Feb 12, 2010 11:00 pm

Ok, i already know, but then how can i upload the same file? (I can not use * operator, it fails) :)
Thanks
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: How to have a "filename" variable?

Post by Daniel, Tech Support » Mon Feb 15, 2010 8:39 am

Hello,

* shouldn't really fail. Please check if there is a file with such name already in the folder and delete it if yes. If it doesn't help, post th error message here.

Best regards,
Daniel, iOpus Support
Loginbug
Posts: 9
Joined: Tue Feb 02, 2010 7:36 pm

Re: How to have a "filename" variable?

Post by Loginbug » Mon Feb 15, 2010 7:57 pm

It does not work because C:\Users\Administrator\Documents\iMacros\Downloads\*.torrent it is not a valid link. :)
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: How to have a "filename" variable?

Post by Daniel, Tech Support » Tue Feb 16, 2010 4:58 pm

Hi, oh, sorry, I didn't realize you're using the name of the saved file later in code. But are you actually sure you can't extract the filename before the dialog pops up? For instance as part of href. I mean in that case you could save that into !VAR1 and use it later.
Well, if not, then you would need to use a scripting language together with iMacros. You would run the first part that downloads the file, figure out the filename in your script (VBS, Javascript, etc.) and then upload it with the second part of the macro.
Daniel, iOpus Support
Loginbug
Posts: 9
Joined: Tue Feb 02, 2010 7:36 pm

Re: How to have a "filename" variable?

Post by Loginbug » Tue Feb 16, 2010 9:11 pm

Thanks. Now it works. :D
Here is the new code.

Code: Select all

//Extract filename.
TAG POS=1 TYPE=A ATTR=CLASS:index&&TXT:* EXTRACT=TXT

//Upload "new.torrent"
TAG POS=1 TYPE=INPUT:FILE FORM=ACTION:edit.php?upload ATTR=NAME:torrentfile CONTENT=C:\Users\Administrator\Documents\iMacros\Downloads\{{!EXTRACT}}.torrent
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: How to have a "filename" variable?

Post by Daniel, Tech Support » Wed Feb 17, 2010 9:14 am

Perfect! :) Great job!
Daniel, iOpus Support
Post Reply