Recent Downloads (requires IDM)

I wanted a recent downloads tab regardless of save location (like in chrome).

Process described below:

  • Internet Download Manager calls a powershell script via the virus checking dialog
  • Powershell script creates a shortcut to the downloaded file.
  • The included button lists all the shortcuts in that folder to easily track down recent downloads.

<?xml version="1.0"?>
<button backcol="none" display="both" dropdown_glyph_slim="yes" hotkey="ctrl+J" icon_size="large" label_pos="right" textcol="#ffffff" type="menu">
	<label>Downloads</label>
	<icon1>#Fluent_UI_DUALTONE:downloads</icon1>
	<button backcol="none" display="both" label_pos="right" textcol="none">
		<label>Downloads</label>
		<icon1>#newmenu</icon1>
		<function type="normal">
			<instruction>Go PATH=&quot;E:\OneDrive\Recent Download Shortcuts&quot; FOLDERCONTENT=&quot;RESOLVESHORTCUTS,sortdate,sortreverse,nodirs,maxfiles=25,hideext,useshell,maxwidth=75,maxdepth=5&quot;</instruction>
		</function>
	</button>
</button>

Powershell (afterdownload.ps1)

param(
  [Parameter(Mandatory = $true)]
  [string]$Target
)

# ==== CONFIG ====
$ShortcutDir = 'E:\OneDrive\Recent Download Shortcuts'
# ================

function New-UniquePath([string]$dir,[string]$base,[string]$ext){
  $p = Join-Path $dir ($base + $ext)
  $i = 2
  while (Test-Path -LiteralPath $p) {
    $p = Join-Path $dir ("{0} ({1}){2}" -f $base, $i, $ext)
    $i++
  }
  $p
}

# -- prep
New-Item -ItemType Directory -Force -Path $ShortcutDir | Out-Null
$Target = $Target.Trim('"')
if (-not [System.IO.File]::Exists($Target)) { exit 0 }

$dir  = [System.IO.Path]::GetDirectoryName($Target)
$name = [System.IO.Path]::GetFileName($Target)

# -- shortcut name: ORIGINAL FILENAME ONLY (deduped)
$safeName = ($name -replace '[\\/:*?"<>|]','_')
$lnkPath  = New-UniquePath $ShortcutDir $safeName '.lnk'

# -- build shortcut (open file directly)
$ws = New-Object -ComObject WScript.Shell
$sc = $ws.CreateShortcut($lnkPath)

$sc.TargetPath       = $Target
$sc.WorkingDirectory = $dir
$sc.IconLocation     = "$Target,0"

$sc.Save()

IDM settings:

Virus scanner program: path to pwsh.exe
Command line parameters: -NoProfile -ExecutionPolicy Bypass -File "path to the .ps1 file" -Target [File]

2 Likes