[Batch] Pack, send to dropbox and get link.

Discussion in 'Scripting' started by lysy.lbn, Apr 26, 2012.

  1. lysy.lbn

    lysy.lbn MDL Member

    Apr 20, 2011
    125
    65
    10
    #1 lysy.lbn, Apr 26, 2012
    Last edited by a moderator: Apr 20, 2017
    Hello mates!

    I have created a simple batch scrpit which Pack (using 7-zip) directly to DB public folder and copy to clipboard public link of file or folder dropped on it (can be used in SendTo menu)

    Requirements:
    Dropbox (running to sync immediately)
    7-zip

    Code:
    Code:
    @echo off
    set dbid=
    set dropbox=%systemdrive%\users\%username%\dropbox\public
    set dropfile=%~n1
    "%programfiles%\7-zip\7z.exe" a "%dropbox%\%dropfile%.7z" ""%*""
    echo http://dl.dropbox.com/u/%dbid%/%dropfile%.7z |clip
    Instructions:
    1. Copy above code
    2. Paste it in notepad
    3. Get the DropBox ID code. (just "copy public link", take numbers which are replaced by "X" in following template: http://dl.dropbox.com/u/XXXXXXXX/public.file and paste it next to dbid=
    4. Change paths if You have any element somewhere else than it's "standard" location
    5. Save with any name You want and .bat or .cmd file extension
    6. You can move saved script to "Send to" to get easy and fast acces to it

    Notes:
    7-zip pack it with "Ultra" compression to 7z format, You can modify commandline options to make it save in other compression levels and to other formats.
    Here you can find good reference to 7-zip commandline options

    Changelog
    26.04.2012 /2 - multiple files / folders could be added at once, archive name will be the same as current highlighted file.
    Changes in script code: end of line 4: ""%1"" changes to ""%*""
    26.04.2012 - Initial "release"

    That's it!

    PS. If You don't have DropBox account yet, You can register via my refferal link to get (and gain me) 500Mb of free space more (2.5Gb in total)

    Tip: If You need more space You can install Experimental Forum Build (first pinned thread) and "test" new Camera Upload feature by importing and uploading photos from anything which pop-up autorun dialog. You'll get 500Mb extra per every 500Mb uploaded up to 3Gb total

    @edit (29 April 2012)
    Code for just copy file (without packing) and get public link is (it'll copy public link of currently "marked" file)
    Code:
    @echo off
    set dbid=
    set dropbox=%systemdrive%\users\%username%\dropbox\public
    set dropfile=%~n1%~x1
    copy "%*" "%dropbox%"
    echo http://dl.dropbox.com/u/%dbid%/%dropfile% |clip
    Hit thanks button if You find it useful :)
     
  2. HALIKUS

    HALIKUS MDL Addicted

    Jul 29, 2009
    527
    369
    30
    #2 HALIKUS, Jun 16, 2012
    Last edited: Jun 16, 2012
    thanks. Little scripts like this automate the mundane and you never appreciate them until you are away from your PC and have to do it elsewhere.

    For
    6. You can move saved script to "Send to" to get easy and fast acces to it
    where do you do that? I have used .reg entries in the past to accomplish this but is it as simple as placing the cmd script in a certain directory for it to display in the send to context menu?