topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 1:12 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Transfer all the opened urls to a folder  (Read 7922 times)

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Transfer all the opened urls to a folder
« on: August 21, 2015, 07:43 AM »
Transfer all the opened urls to a folder

Suppose we have 20 tabs opened in firefox
HOw can i create a folder in desktop containing all the urls of the opened tabs ?

Best Regards
 :huh:

IainB

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 7,540
  • @Slartibartfarst
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Transfer all the opened urls to a folder
« Reply #1 on: August 21, 2015, 09:51 AM »
From DC forum: Re: Firefox Extensions: OneTab is well worth trying out.
From DC Forum: Re: Transfer all opened tabs in browser to a txt file
^^ Yes, OneTab would be brilliant for this and other browsing information capture purposes. I have been trialing it for a couple of weeks, and it's very nifty.   :Thmbsup:

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Transfer all the opened urls to a folder
« Reply #2 on: August 21, 2015, 11:30 AM »
From DC forum: Re: Firefox Extensions: OneTab is well worth trying out.
From DC Forum: Re: Transfer all opened tabs in browser to a txt file
^^ Yes, OneTab would be brilliant for this and other browsing information capture purposes. I have been trialing it for a couple of weeks, and it's very nifty.   :Thmbsup:

 :tellme: :tellme: :tellme: :tellme: :tellme: :tellme: :tellme:

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Transfer all the opened urls to a folder
« Reply #3 on: August 21, 2015, 01:15 PM »
Ejem.

I don't see the option to create inside a folder the urls with the tabs.

There is an indirect way to do it ?

Best Regards
 :-*

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Transfer all the opened urls to a folder
« Reply #4 on: August 21, 2015, 02:49 PM »
 :-[
Really i can't find it.
I am a dummyyyyyyyy!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 ;D

IainB

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 7,540
  • @Slartibartfarst
    • View Profile
    • Read more about this member.
    • Donate to Member

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,641
    • View Profile
    • Donate to Member
Re: Transfer all the opened urls to a folder
« Reply #6 on: August 23, 2015, 09:32 PM »
I think what he wants is that all opened tabs are created as individual Internet shortcuts within a folder on the Desktop.

IainB

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 7,540
  • @Slartibartfarst
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Transfer all the opened urls to a folder
« Reply #7 on: August 23, 2015, 10:32 PM »
^^ You could be correct!    :D

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,641
    • View Profile
    • Donate to Member
Re: Transfer all the opened urls to a folder
« Reply #8 on: August 25, 2015, 08:19 PM »
Stupid me, this post should have been in this thread.

4wd

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 5,641
    • View Profile
    • Donate to Member
Re: Transfer all the opened urls to a folder
« Reply #9 on: September 12, 2015, 11:38 PM »
An updated version of the script in this post, now handles Firefox, Pale Moon, IceDragon, Cyberfox, SeaMonkey, and K-Meleon (and more if you add the relevant code).

UPDATED: Generates text file URI list and/or folder with shortcuts.

2015-09-23 18_25_08.pngTransfer all the opened urls to a folder

Requirements:
Powershell v3+

Code: PowerShell [Select]
  1. <#
  2. .SYNOPSIS
  3.    Reads Firefox compatible JSON session file and creates URI shortcuts in a folder on the Desktop.
  4. .DESCRIPTION
  5.    See above.
  6. .PARAMETER <paramName>
  7.    None
  8. .EXAMPLE
  9.    C:\> powershell.exe -sta -noprofile -executionpolicy bypass -File ".\JSON2Shortcut.ps1"
  10. #>
  11.  
  12. Function Create-File {
  13.   $file = ("Tabs-" + "{0:yyyy}" -f (Get-Date)) + ("{0:MM}" -f (Get-Date)) + ("{0:dd}" -f (Get-Date)) `
  14.             + ('{0:hh}' -f (Get-Date)) + ('{0:mm}' -f (Get-Date)) + ('{0:ss}' -f (Get-Date)) + '.txt'
  15.   $desktop = [Environment]::GetFolderPath("Desktop")
  16.  
  17. # Our new file path
  18.   $tFile = $desktop + '\' + $file
  19. # Create the file
  20.   New-Item -Path $tFile -ItemType File | Out-Null
  21.   Return $tFile
  22. }
  23.  
  24. Function Create-Folder {
  25. # Create a folder on the Desktop based on current date/time
  26.   $folder = ("Tabs-" + "{0:yyyy}" -f (Get-Date)) + ("{0:MM}" -f (Get-Date)) + ("{0:dd}" -f (Get-Date)) `
  27.             + ('{0:hh}' -f (Get-Date)) + ('{0:mm}' -f (Get-Date)) + ('{0:ss}' -f (Get-Date))
  28.   $desktop = [Environment]::GetFolderPath("Desktop")
  29.  
  30.   New-Item -Path $desktop -Name $folder -ItemType Directory | Out-Null
  31.  
  32. # Our new folder path
  33.   Return $desktop + '\' + $folder
  34. }
  35.  
  36. # Cycles through the Tab entries in Firefox compatible JSON files, (eg. Cyberfox, Pale Moon, IceDragon)
  37. Function Cycle-TabsFf {
  38.   Param(
  39.     [string]$tPath="",
  40.     [string]$uriFile=""
  41.   )
  42. # Cycle through the Tabs object only getting the Entries for non-Hidden ones
  43.   for($i=0; $i -lt $opentabs.windows.tabs.Count; $i++) {
  44.     if (!$opentabs.windows.tabs.hidden[$i]) {
  45.       if ($Cb_Shortcut.IsChecked) {
  46.         Create-Shortcut $tPath $opentabs.windows.tabs[$i].entries[-1].title.Trim() $opentabs.windows.tabs[$i].entries[-1].url
  47.       }
  48.       if ($Cb_File.IsChecked) {
  49.         Out-File -Encoding utf8 -FilePath $uriFile -InputObject $opentabs.windows.tabs[$i].entries[-1].url -Append
  50.       }
  51.     }
  52.   }
  53. }
  54.  
  55. # Cycles through the Tab entries in K-Meleon compatible JSON files
  56. Function Cycle-TabsKm {
  57.   Param(
  58.     [string]$tPath="",
  59.     [string]$uriFile=""
  60.   )
  61.   $opentabs.sessions[-1].windows.tabs.Count
  62. # Cycle through the Tabs
  63.   for($i=0; $i -lt $opentabs.sessions[-1].windows.tabs.Count; $i++) {
  64.     if ($Cb_Shortcut.IsChecked) {
  65.       Create-Shortcut $tPath $opentabs.sessions[-1].windows.tabs[$i].entries[-1].title.Trim() $opentabs.sessions[-1].windows.tabs[$i].entries[-1].url
  66.     }
  67.     if ($Cb_File.IsChecked) {
  68.       Out-File -Encoding utf8 -FilePath $uriFile -InputObject $opentabs.sessions[-1].windows.tabs[$i].entries[-1].url -Append
  69.     }
  70.   }
  71. }
  72.  
  73. Function Create-Shortcut {
  74.   Param(
  75.     [string]$Path,
  76.     [string]$Title,
  77.     [string]$url
  78.   )
  79.   if ($Title.Length -gt 15) { $Title = $Title.Substring(0, 15) }
  80.   $Title = $Path + '\' + $Title + '_' + (Get-Random -Maximum 1000) + '.url'
  81.  
  82. # Create a Shortcut with Windows PowerShell using Windows Scripting interface
  83.   $WScriptShell = New-Object -ComObject WScript.Shell
  84.   $Shortcut = $WScriptShell.CreateShortcut($Title)
  85.   $Shortcut.TargetPath = $url
  86.   $Shortcut.Save()
  87. }
  88.  
  89. Function Remove-InvalidFileNameChars {
  90.   param(
  91.     [Parameter(Mandatory=$true,
  92.       Position=0,
  93.       ValueFromPipeline=$true,
  94.       ValueFromPipelineByPropertyName=$true)]
  95.     [String]$Name
  96.   )
  97.  
  98.   $invalidChars = [IO.Path]::GetInvalidFileNameChars() -join ''
  99.   $re = "[{0}]" -f [RegEx]::Escape($invalidChars)
  100.   return ($Name -replace $re)
  101. }
  102.  
  103. Function Read-JSON {
  104.   Param(
  105.     [string]$file
  106.   )
  107.   if (!(Test-Path -Path $file)) { Exit }
  108.   $global:opentabs = (Get-Content $file) -join "`n" | ConvertFrom-Json
  109. }
  110.  
  111. Function Load-Dialog {
  112.   Param(
  113.     [Parameter(Mandatory=$True,Position=1)]
  114.     [string]$XamlPath
  115.   )
  116.  
  117.   [xml]$Global:xmlWPF = Get-Content -Path $XamlPath
  118.  
  119.   #Add WPF and Windows Forms assemblies
  120.   try{
  121.     Add-Type -AssemblyName PresentationCore,PresentationFramework,WindowsBase,system.windows.forms
  122.   } catch {
  123.     Throw "Failed to load Windows Presentation Framework assemblies."
  124.   }
  125.  
  126.   #Create the XAML reader using a new XML node reader
  127.   $Global:xamGUI = [Windows.Markup.XamlReader]::Load((new-object System.Xml.XmlNodeReader $xmlWPF))
  128.  
  129.   #Create hooks to each named object in the XAML
  130.   $xmlWPF.SelectNodes("//*[@Name]") | %{
  131.     Set-Variable -Name ($_.Name) -Value $xamGUI.FindName($_.Name) -Scope Global
  132.   }
  133. }
  134.  
  135. # Check Powershell version, ConvertFrom-JSON requires v3+
  136. If($PSVersionTable.PSVersion.Major -lt 3) {
  137.   (new-object -ComObject wscript.shell).Popup("Script requires Powershell V3",0,"OK")
  138.   Exit
  139. }
  140.  
  141. # Read JSON2Shortcut.ini file for paths of JSON files for various browsers
  142. Get-Content "JSON2Shortcut.ini" | foreach-object -begin {$h=@{}} -process { $k = [regex]::split($_,'='); `
  143.   if(($k[0].CompareTo("") -ne 0) -and ($k[0].StartsWith("[") -ne $True)) { $h.Add($k[0], $k[1]) } }
  144. # $h.Get_Item("Firefox")
  145.  
  146.  
  147. #Required to load the XAML form and create the PowerShell Variables
  148. Load-Dialog -XamlPath '.\JSON2Shortcut.xaml'
  149.  
  150. #Events
  151. $Bt_Firefox.add_Click({
  152.   Read-Firefox $h.Get_Item("Firefox")
  153.   if ($Cb_Shortcut.IsChecked -or $Cb_File.IsChecked) {
  154.     if ($Cb_Shortcut.IsChecked) {$scPath = Create-Folder}
  155.     if ($Cb_File.IsChecked) {$scFile = Create-File}
  156.     Cycle-TabsFf $scPath $scFile
  157.   }
  158. })
  159.  
  160. $Bt_Palemoon.add_Click({
  161.   Read-JSON $h.Get_Item("Palemoon")
  162.   if ($Cb_Shortcut.IsChecked -or $Cb_File.IsChecked) {
  163.     if ($Cb_Shortcut.IsChecked) {$scPath = Create-Folder}
  164.     if ($Cb_File.IsChecked) {$scFile = Create-File}
  165.     Cycle-TabsFf $scPath $scFile
  166.   }
  167. })
  168.  
  169. $Bt_Cyberfox.add_Click({
  170.   Read-JSON $h.Get_Item("Cyberfox")
  171.   if ($Cb_Shortcut.IsChecked -or $Cb_File.IsChecked) {
  172.     if ($Cb_Shortcut.IsChecked) {$scPath = Create-Folder}
  173.     if ($Cb_File.IsChecked) {$scFile = Create-File}
  174.     Cycle-TabsFf $scPath $scFile
  175.   }
  176. })
  177.  
  178. $Bt_IceDragon.add_Click({
  179.   Read-JSON $h.Get_Item("IceDragon")
  180.   if ($Cb_Shortcut.IsChecked -or $Cb_File.IsChecked) {
  181.     if ($Cb_Shortcut.IsChecked) {$scPath = Create-Folder}
  182.     if ($Cb_File.IsChecked) {$scFile = Create-File}
  183.     Cycle-TabsFf $scPath $scFile
  184.   }
  185. })
  186.  
  187. $Bt_SeaMonkey.add_Click({
  188.   Read-JSON $h.Get_Item("SeaMonkey")
  189.   if ($Cb_Shortcut.IsChecked -or $Cb_File.IsChecked) {
  190.     if ($Cb_Shortcut.IsChecked) {$scPath = Create-Folder}
  191.     if ($Cb_File.IsChecked) {$scFile = Create-File}
  192.     Cycle-TabsFf $scPath $scFile
  193.   }
  194. })
  195.  
  196. $Bt_KMeleon.add_Click({
  197.   Read-JSON $h.Get_Item("Kmeleon")
  198.   if ($Cb_Shortcut.IsChecked -or $Cb_File.IsChecked) {
  199.     if ($Cb_Shortcut.IsChecked) {$scPath = Create-Folder}
  200.     if ($Cb_File.IsChecked) {$scFile = Create-File}
  201.     Cycle-TabsKm $scPath $scFile
  202.   }
  203. })
  204.  
  205. #Launch the window
  206. $xamGUI.ShowDialog() | out-null

Installation/Execution:
  • Extract all files in the archive to a folder
  • Edit JSON2Shortcut.ini so that it has the correct paths for each browser, (you can use full paths or wildcards as long as it can hit the right file)
  • Double-click the shortcut icon to run

DISCLAIMER: Works for me.
« Last Edit: September 23, 2015, 05:39 AM by 4wd »

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Transfer all the opened urls to a folder
« Reply #10 on: October 19, 2015, 06:01 PM »
 :-[
Ow I have just seen this interesting thing again

Sometimes I wish to have a head over my shoulders, but fortunately others have this advantage. May be the next year i will try to discover how many times i have made the same question again and again.
 :-[ :(