How to download file from clipboard URL to folder path?

Apparently, this can be done in Windows without additional tools using PowerShell (as long as the file size is not too big), but the file name has to be passed separately, so it cannot be done as a 1-click-button using standard dopus code I guess?

This works, but the file name has to be entered manually:

@set filename={dlgstrings|File name|{clip}}

PowerShell.exe -Command wget "{clip}" -OutFile """{sourcepath}{$filename}"""

I tried to convert the code to VBScript, but couldn't figure it out. Can the sourcepath be accessed from the VBScript within a button?

@nodeselect
ClipboardData = DOpus.GetClip("url")
If InStr(ClipboardData, "://") > 0 Then
    ' Extract the filename from the URL
    URLParts = Split(ClipboardData, "/")
    Filename = URLParts(UBound(URLParts))

    ' Resolve the source path
    SourcePath = DOpus.FSUtil.Resolve("{sourcepath}")

    ' Display a message with the extracted filename
    DOpus.Output "Filename extracted: " & Filename

    ' Run the PowerShell command with the resolved paths
    CreateObject("Wscript.Shell").Run "PowerShell.exe -Command wget """ & ClipboardData & """ -OutFile """ & SourcePath & "\" & Filename & """"
Else
    DOpus.Output "No valid URL found in clipboard."
End If

I've also tried a different button using Internet Download Manager, but IDM didn't accept that when a space was in the sourcepath folder name, doesn't matter if enclosed in double quotes or not. (Also, it requires the IDM to be installed in the first place.)

C:\Program Files (x86)\Internet Download Manager\IDMan.exe /d {clip} /p {sourcepath} /q /n

These are very advanced questions to ask if you’re still not sure about purchasing Opus or not.

(There are a couple of people who keep making new forum accounts to pretend to be new users when they aren’t, so we’re weary of spending time answering advanced questions from people who haven’t linked their accounts, sorry.)

After spending hours unsuccessfully trying to get this to work, you calling this an "advanced question" feels almost a little comforting. :laughing:
Don't worry, I'll just leave the question here then and will feel free to remind you after my account is finally linked.

Thanks for linking!

If you need to modify the clipboard string to extract the filename, that's best done via scripting, at least currently.

So you're on the right path.

Yes, clickData.func.sourcetab.path will get you the source path within script code.

{sourcepath} can also be used within strings passed to the Opus Command object. So you could use that instead of the WSH Run method Windows provides. (But WSH Run is fine, and both it and the Command object can be more suited to some things than others.)

As an aside, if you make a new toolbar button and set it to one of the script types, it will give you the Default Script, which contains examples of how to do some common things, including get the source path:

That script also shows how to use the Opus Command object.

Thanks. I've managed to finish the button.

Good. can i download full pages with there contents?

I'm just using this to download smaller or average sized files directly to a folder instead of having to use the download dialog of a browser to choose the file location.

Note that my button doesn't use the real wget (external application) but uses wget as an alias for an internal windows function. The windows function needs a file name to be specified, so it probably cannot do what you're asking.

If you want to rip the whole contents of a website, you might need an external application. I guess Internet Download Manager can probably do something like this or download and set up the free wget command line application. You can check this site where someone asks for something similar:

If you manage to get Internet Download Manager or wget to work from within Dopus, please share how to do that, because I've tried that too before I switched to the windows function.