Fielding Posted August 26, 2015 Share Posted August 26, 2015 With this script i try to convert in urls in my desktop all the bookmarks in firefox <# .SYNOPSIS Reads Firefox recovery.js JSON file and creates URI shortcuts in a folder on the Desktop. .DESCRIPTION See above. .PARAMETER <paramName> None .EXAMPLE C:> powershell.exe -noprofile -executionpolicy bypass -File ".JSON2Shortcut.ps1" #> Function Remove-InvalidFileNameChars { param( [Parameter(Mandatory=$true, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)] [String]$Name ) $invalidChars = [IO.Path]::GetInvalidFileNameChars() -join '' $re = "[{0}]" -f [RegEx]::Escape($invalidChars) return ($Name -replace $re) } # Check Powershell version, ConvertFrom-JSON requires v3+ If($PSVersionTable.PSVersion.Major -lt 3) { (new-object -ComObject wscript.shell).Popup("Script requires Powershell V3",0,"OK") Exit } # Check for and read the recovery.js file and convert from JSON to objects if (!(Test-Path -Path ~AppDataR*M*F*P**s*recovery.js)) { Exit } $opentabs = (Get-Content ~AppDataR*M*F*P**s*recovery.js) | ConvertFrom-Json # Firefox # Create a folder on the Desktop based on current date/time $folder = ("Tabs-" + "{0:yyyy}" -f (Get-Date)) + ("{0:MM}" -f (Get-Date)) + ("{0:dd}" -f (Get-Date)) ` + ('{0:hh}' -f (Get-Date)) + ('{0:mm}' -f (Get-Date)) + ('{0:ss}' -f (Get-Date)) $desktop = [Environment]::GetFolderPath("Desktop") New-Item -Path $desktop -Name $folder -ItemType Directory | Out-Null # Our new folder path $scPath = $desktop + '' + $folder # Cycle through the Tabs object only getting the Entries for non-Hidden ones for($i=0; $i -lt $opentabs.windows.tabs.Count; $i++) { if (!$opentabs.windows.tabs.hidden[$i]) { # Grab the Title of the page, trim to 15 characters, add a random number, and append .url # (This becomes our shortcut name) $scName = (Remove-InvalidFileNameChars $opentabs.windows.tabs[$i].entries[-1].title.Trim()) if ($scName.Length -gt 15) { $scName = $scName.Substring(0, 15) } $scName = $scPath + '' + $scName + '_' + (Get-Random -Maximum 1000) + '.url' # Target is the URL from the object $scTarget = $opentabs.windows.tabs[$i].entries[-1].url # Create a Shortcut with Windows PowerShell using Windows Scripting interface $WScriptShell = New-Object -ComObject WScript.Shell $Shortcut = $WScriptShell.CreateShortcut($scName) $Shortcut.TargetPath = $scTarget $Shortcut.Save() } } I have windows 8.1 running and installed windows powershell in C:WindowsSystem32WindowsPowerShellv1.0 version 3.0 How can i depure my problem ? Best Regards Link to comment Share on other sites More sharing options...
justsomeguy Posted August 26, 2015 Share Posted August 26, 2015 I don't know what depure means, but what specifically is the problem? Link to comment Share on other sites More sharing options...
Fielding Posted August 26, 2015 Author Share Posted August 26, 2015 depure i means debug. the script don't go well for me and i don't know how to solve . My recovery.js is : Y:FIREFOX PERFILESPEPEsessionstore-backupsrecovery.js In the line : C:> powershell.exe -noprofile -executionpolicy bypass -File ".JSON2Shortcut.ps1" i have put finally C:> powershell.exe -noprofile -executionpolicy bypass -File "JSON2Shortcut.ps1" with the script JSON2Shorcut.ps1 in the folder : C:WindowsSystem32WindowsPowerShellv1.0 where the executable powershell.exe is What am i doing bad ? Best Regards Link to comment Share on other sites More sharing options...
justsomeguy Posted August 26, 2015 Share Posted August 26, 2015 The .ps1 file needs to be in the working directory, which is whatever directory you're in when you run that command. If the prompt is at c:, then the .ps1 file needs to be there unless you specify the full path to the file. If you only give a filename then it looks in the working directory, not wherever the executable is. Link to comment Share on other sites More sharing options...
Fielding Posted August 27, 2015 Author Share Posted August 27, 2015 I have moved the script from C:WindowsSystem32WindowsPowerShellv1.0JSON2Shortcut.ps1 to c:JSON2Shorcut.ps1 but i don't observ interaction after execute Best Regards Link to comment Share on other sites More sharing options...
justsomeguy Posted August 27, 2015 Share Posted August 27, 2015 What happens when you run the command? What is supposed to happen? Link to comment Share on other sites More sharing options...
Fielding Posted August 27, 2015 Author Share Posted August 27, 2015 It's Solved. Thank you very much for your help Link to comment Share on other sites More sharing options...
Fielding Posted August 27, 2015 Author Share Posted August 27, 2015 What happens when you run the command? What is supposed to happen? This above : try to convert in urls in my desktop all the bookmarks in firefox Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now