topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Wednesday June 18, 2025, 6:56 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

Recent Posts

Pages: prev1 ... 12 13 14 15 16 [17] 18 19 20 21 22 ... 225next
401
Truncate is fine as long as it keeps the file extension. ;)
For instance : If a filename is longer than 200 characters (let's say that basically my folder subfolder paths are always less than 60 characters), truncate the last part of the filename to less than 200 characters and keep the extension.

OK, see what I can do.

What happens if the path is longer than 260 characters?

- It doesn't 'unzip' rar files (it is working fine for zip files).

Strange, works fine with zip and rar files here.
Maybe a later version of the 7z libraries are required for them or just switch to calling 7zsa.exe instead.

Do you have a rar file you can let me play with?

- If possible do not delete the original zip or rar file if there is an error unzipping.

OK, have to see if there is an error code returned.

- It does not find zip files inside zip files (even if Run it twice). It is maybe because it doesn't look for zip and rar files inside subfolders ?

That's because I missed the word 'recursively' in your OP.  :-[

Guess it'd have to keep looping until there were no archives left or something ... have to think about it.

>PDFTextChecker.exe.  This version uses the pdftotext.exe to extract any text from the PDF and then checks the resulting text file for any alphanumeric characters.  If any are found, it considers that searchable.

Yeah, I created an image PDF for a test.  After running pdftotext.exe on it there was a much smaller text file with 'Page 1/1' in it.  So might end up thinking image PDFs are text PDFs due to headers/footers in the PDF.

If there's not likely to be headers/footers then it'd be easy enough to check and act on the result.

I realize that I also remove some strange characters in the pdf filenames like accents, °, !, +, & , ..etc.. with the freeware "Bulk Rename Utility" as PDFTextChecker can't do a check on them. I don't know if it is possible this in Powershell ?

Should be easy enough by removing any characters not in the old ASCII table.

BTW, just as a matter of interest, are any files other than PDFs required?

ie. Extract archives then delete anything that's too small or not a PDF.
402
Requires (in the same folder):
7z.exe
7z.dll
itextsharp.dll

Attached the versions I'm using, (for x64 only).

Set the variables at the start as required.

jityPDFt3.ps1

Code: PowerShell [Select]
  1. <#
  2.   Copy 7z.exe and 7z.dll into the same folder as this script.
  3.  
  4.   Requires iTextSharp.dll in the same folder as this script - can be extracted from
  5.   itextsharp.5.5.13.1.nupkg by changing extension to .zip - package can be downloaded from
  6.   https://github.com/itext/itextsharp/releases
  7. #>
  8.  
  9. # Initial folder with archives
  10. $folder1 = 'G:\test\folder1'
  11. # Folder for text based PDFs
  12. $folder2 = 'G:\test\Text'
  13. # Folder for non-text PDFs
  14. $folder3 = 'G:\test\Image'
  15. # Threshold to determine whether PDF is text or image based, equals minimum number of
  16. # lines of text to be detected before PDF is considered text based.
  17. # The threshold applies to the number of lines detected across first 5 pages, (or all
  18. # if less than 5 pages).
  19. $TextPDFThreshold = 20
  20. # Delete extracted archives: $true or $false
  21. # Archives that fail extraction won't be deleted regardless of this setting.
  22. $delArc = $false
  23. <# ------------------- #>
  24.  
  25. Add-Type -Path ".\itextsharp.dll"
  26.  
  27. Function Delete-Dupes {
  28. Get-ChildItem "$($folder1)\*" -File -Include *.zip,*.rar,*.7z,*.pdf | Get-FileHash | Group -Property Hash | Where { $_.count -gt 1 } `
  29.   | % { $_.group | Select -Skip 1 } | Remove-Item -Force
  30. }
  31.  
  32. Function Extract-Items {
  33.   for ($j = 0; $j -lt 2; $j++) {
  34.     if ($j -ne 1) {
  35.       $files = Get-ChildItem "$($folder1)\*" -File -Include *.zip,*.rar,*.7z
  36.     } else {
  37.       $files = Get-ChildItem "$($folder1)" -Include *.zip,*.rar,*.7z -Recurse
  38.     }
  39.     for ($i = 0; $i -lt $files.Count; $i++) {
  40.       $tempdest = "$(([io.path]::GetDirectoryName($files[$i])))\$(([io.path]::GetFileNameWithoutExtension($files[$i])))"
  41.       & ".\7z.exe" "x" "-y" "$($files[$i])" "-o$tempdest" | Out-Null
  42.       if ($? -and $delArc) {
  43.         Remove-Item "$($files[$i])" -Force
  44.       }
  45.     }
  46.   }
  47. }
  48.  
  49. Function Delete-SmallPDF {
  50.   param (
  51.     [bool]$delSmall
  52.   )
  53.   if ($delSmall) {
  54.     Get-ChildItem "$($folder1)\*" -Include *.pdf -Recurse | ? {$_.length -lt 2048} | % {Remove-Item $_.fullname -Force}
  55.   }
  56.   Get-ChildItem "$($folder1)" -recurse | Where {$_.PSIsContainer -and `
  57.     @(Get-ChildItem -Lit $_.Fullname -r | Where {!$_.PSIsContainer}).Length -eq 0} | Remove-Item -recurse
  58.   Get-ChildItem "$($folder2)" -recurse | Where {$_.PSIsContainer -and `
  59.     @(Get-ChildItem -Lit $_.Fullname -r | Where {!$_.PSIsContainer}).Length -eq 0} | Remove-Item -recurse
  60.   Get-ChildItem "$($folder3)" -recurse | Where {$_.PSIsContainer -and `
  61.     @(Get-ChildItem -Lit $_.Fullname -r | Where {!$_.PSIsContainer}).Length -eq 0} | Remove-Item -recurse
  62. }
  63.  
  64. Function Fix-FileNames {
  65.   $files = Get-ChildItem "$($folder1)\*" -Include *.pdf -Recurse
  66.   for ($i = 0; $i -lt $files.Count; $i++) {
  67.     $j = 0
  68.     $noSpecialChars = (Convert-ToLatinCharacters "$([io.path]::GetFileNameWithoutExtension($files[$i]))") -replace '[\[\]]', '_'
  69.     $tempName = "$(([io.path]::GetDirectoryName($files[$i])))\$($noSpecialChars)"
  70.     $pathLength = ([io.path]::GetDirectoryName($files[$i])).Length
  71.     $totalLength = $tempName.Length + 4
  72.     if ($pathLength -lt 248) {
  73.       if ($totalLength -gt 251) {
  74.         $fn1 = "$($noSpecialChars.Substring(0, (251 - $pathLength)))"
  75.       } else {
  76.         $fn1 = "$($noSpecialChars)"
  77.       }
  78.     } else {
  79.       $fn1 = $null
  80.       break
  81.     }
  82.     if (($fn1 -ne $null) -and ($fn1 -ne "$([io.path]::GetFileNameWithoutExtension($files[$i]))")) {
  83.       $newName = "$([io.path]::GetDirectoryName($files[$i]))\$($fn1).pdf"
  84.       if (Test-Path $newName) {
  85.         do {
  86.           $j++
  87.           $k = "{0:0000}" -f $j
  88.           $newName = "$([io.path]::GetDirectoryName($files[$i]))\$($fn1)_$($k).pdf"
  89.         } while (Test-Path $newName)
  90.       }
  91.       Rename-Item -LiteralPath "$($files[$i])" "$($newName)"
  92.     }
  93.   }
  94. }
  95.  
  96. Function Convert-ToLatinCharacters {
  97. # https://lazywinadmin.com/2015/05/powershell-remove-diacritics-accents.html
  98. # https://lazywinadmin.com/2015/08/powershell-remove-special-characters.html
  99.   param (
  100.     [string]$inputString
  101.   )
  102.   return ([Text.Encoding]::ASCII.GetString([Text.Encoding]::GetEncoding("Cyrillic").GetBytes($inputString)) -replace '[/;]|[^\p{L}\p{Nd}/(/)/_/ \[\]]', '')
  103. }
  104.  
  105. Function Check-PDF {
  106. # https://superuser.com/questions/1278479/search-pdf-contents-with-powershell-and-output-a-file-list/1278521#1278521
  107.   $files = (Get-ChildItem "$($folder1)\*" -Include *.pdf -Recurse)
  108.   for ($i = 0; $i -lt $files.Count; $i++) {
  109.     if ($files[$i].FullName.Length -lt 260) {
  110.       Write-Host "Processing - $($files[$i]) ..."
  111.       $reader = New-Object iTextSharp.text.pdf.pdfreader -ArgumentList $files[$i].FullName
  112.       if ($?) {
  113.         $linesOfText = 0
  114.         for ($page = 1; $page -le $reader.NumberOfPages; $page++) {
  115.           $pageText = [iTextSharp.text.pdf.parser.PdfTextExtractor]::GetTextFromPage($reader, $page).Split([char]0x000A)
  116.           $linesOfText += $pageText.Count
  117.           if ($page -gt 4) {
  118.             break
  119.           }
  120.         }
  121.         $reader.Close()
  122.         if ($linesOfText -ge $TextPDFThreshold) {
  123.           $outfile = "$($folder2)\$(($files[$i].FullName).Substring($folder1.Length))"
  124.           If(-Not (Test-Path (Split-Path -Path $outfile))) {
  125.             New-Item (Split-Path -Path $outfile) -Type Directory | Out-Null
  126.           }
  127.           Move-Item "$($files[$i])" -Destination "$($outfile)"
  128.         } else {
  129.           $outfile = "$($folder3)\$(($files[$i].FullName).Substring($folder1.Length))"
  130.           If(-Not (Test-Path (Split-Path -Path $outfile))) {
  131.             New-Item (Split-Path -Path $outfile) -Type Directory | Out-Null
  132.           }
  133.           Move-Item "$($files[$i])" -Destination "$($outfile)"
  134.         }
  135.       }
  136.     }
  137.   }
  138. }
  139.  
  140.  
  141. Write-Host 'Removing duplicate archives ...'
  142. Delete-Dupes
  143. Write-Host 'Extracting archives ...'
  144. Extract-Items
  145. Write-Host 'Deleting small PDFs and empty folders ...'
  146. Delete-SmallPDF $true
  147. Write-Host 'Removing diacritics, etc, and fix long paths ...'
  148. Fix-FileNames
  149. Write-Host 'Testing for text PDFs ...'
  150. Check-PDF
  151. Write-Host 'Deleting empty folders ...'
  152. Delete-SmallPDF $false
  153. Write-Host 'Finished ...'

No longer requires PDFTextChecker, uses the itextsharp library.
403
The main.bat file (or powershell?) should do the following :

1) delete duplicate files (MD5 checksum?)
(maybe using this powershell script https://n3wjack.net/...ith-just-powershell/ ?)

Looks good

2) unzip+unrar zip and rar files recursively (and once done delete the originals) of "folder1"
I thought using this old coding snack in ahk (RecurUnZip https://www.donation....msg192366#msg192366) but I need something automatic as my "folder1" path doesn't change.
(I have tried to adapt this powershell code with its comments alas unsucessfully https://superuser.co...-the-archives/620077 !)

Code: PowerShell [Select]
  1. <#
  2.   Uses 7Zip4Powershell module: https://www.powershellgallery.com/packages/7Zip4Powershell/1.9.0
  3.  
  4.   NOTE: You need to use a Admin Powershell Console to install the module.
  5.  
  6. .\Extract.ps1 <archive>
  7.  
  8. <archive> = full path to archive with quotes if necessary
  9. #>
  10.  
  11.  
  12. Param (
  13.   [string]$archive
  14. )
  15.  
  16. # Below, change the R:\folder1 to point to your particular location
  17. $tempdest = "R:\folder1\$(([io.path]::GetFileNameWithoutExtension($archive)))"
  18. Expand-7Zip -ArchiveFileName $archive -TargetPath $tempdest
  19.  
  20. Remove-Item "$($archive)" -Force

3) Reduce filepath to less than 260 characters (because some old programs can't open filepath that are long than 260 characters them later on). I manually use "Path Scanner" (http://www.parhelia-...canner/Download.aspx)

How would you determine what the shortened name should be?
Truncate, remove every second character, etc, etc.

You can't use extended-length paths ?

4) Delete pdf files that are less than 2ko (because they are garbage) (I manually do this by using the freeware Everything and rank by size pdf files)

Same as you're using here for files <3kb.

Code: PowerShell [Select]
  1. Get-ChildItem $path -Filter *.pdf -recurse -file | ? {$_.length -lt 2048} | % {Remove-Item $_.fullname -Force}

5) Run PDFTextChecker (https://www.donation....msg255322#msg255322) on "folder1" by itself (it creates 2 files "!Not_Searchable.txt" and "!Searchable.txt"). Move the Not_Searchable pdf files in "folder2" and Searchable files in "folder3" (maybe using this old coding snack https://www.donation....msg330784#msg330784 ?).

Would be a simple matter of parsing the output files and issuing the appropriate Move-Item sub-command - I'm assuming you also want to keep the existing folder structure?

Then I use ABBYY Finereader 12 Corporate (not the last version which limits the number of page you can OCR per month !) which does an OCR automatically every day of "folder2" (be careful if you follow this process as it sometimes delete pdf files without warnings! So use the options to keep original files in a separated folder!

Probably be easier to just clone folder2 to folder2-orig and then let it run on folder2 letting it delete the originals.


I'll look at patching something together, might be a few days though.  Also, I don't have ABBYY Finereader so can you give me the various commandline options, (both to keep original or not).
404
General Software Discussion / Re: Hosting photos on your own site
« Last post by 4wd on November 01, 2019, 12:31 AM »
jAlbum - was free, now looks to be paid - did have a link to the last free version here, looks like it's gone.

v9.6.1 looks to have been the last free version.

Untested download link (Software Informer), (VT analysis).
405
Coding Snacks / Re: Killing app the way Alfred can in OSX
« Last post by 4wd on October 31, 2019, 10:36 PM »
A search for equivalent of alfred for windows threw up this Reddit which led to this: Wox

An effective launcher for windows
A full-featured launcher, access programs and web contents as you type. Be more productive ever since.

Wox is free for use and open-sourced at Github, Try it now!

It has a load of plugins available including for process killing.

preview-c9e52ccf-7406-469f-9213-ad5f0fa80ec9.png

Actually, it looks pretty good ... might have to move FARR aside for a little testing  ;)

There's a couple of others mentioned also: Hain; Zazu
406
Found Deals and Discounts / Re: Finally: PORTABLE Revo Uninstaller on sale!
« Last post by 4wd on October 31, 2019, 07:03 PM »
Are these still a favorite here?

Just upgraded my v3 portable to v4 because it's a better deal than the installer version, (you get a slightly better deal than BdJ if you already have a licensed copy).

The online database of installed program tracelogs, (although program versions are usually different), and inclusion of Windows Apps are a couple of good improvements in v4.

I've got licensed v3 installed version but on machines that run OS that won't be upgraded, (WHS2011).
407
Coding Snacks / Re: Killing app the way Alfred can in OSX
« Last post by 4wd on October 28, 2019, 09:59 PM »
Perhaps a FARR plugin would be the easiest way to do it?

FARR's ProcessKill Plugin here:  http://www.dcmembers...om/taichi/downloads/

I use the last version (0.0.7) and it works well.

:-[ ... well there you go ... I should pay more attention ;D
408
Coding Snacks / Re: Killing app the way Alfred can in OSX
« Last post by 4wd on October 28, 2019, 07:09 AM »
I think he's after something like, for example, a FARR plugin for killing processes.

You'd type in kill xyz and a list of processes containing the string xyz, (the list updating as more characters were entered), would be listed which then can be terminated by selecting.

Perhaps a FARR plugin would be the easiest way to do it?
409
General Software Discussion / Re: download online video
« Last post by 4wd on October 27, 2019, 05:25 PM »
FWIW, VideoProc downloaded the video, (1280x720), without a problem - it's just another frontend to youtube-dl.
410
General Software Discussion / Re: download online video
« Last post by 4wd on October 26, 2019, 06:54 PM »
You could install SlimJet, (as a portable app), and use it's tab recorder - it'll record anything in the current tab even if it's behind other program windows or you switch to another tab, (let it run in the background and use another tab for browsing).

2019-10-27 10_43_06-DonationCoder.com Forum - Index - Slimjet.png

It'll save it as a WEBM container with VP9/OPUS codecs in your default download folder - can be easily converted to something else using FFMPEG.

Otherwise, send me the link and I'll have a go.
411
VideoProc 3.4 is up as a give away: https://www.videopro...to-mp4-converter.htm

Activate before November 18

In case no-one realises, you can then uninstall and reinstall, (this version), at any time provided you have saved the activation file.

FWIW, you can also extract the installer and copy/rename the {app} folder somewhere - no need to install it, (that I've noticed 'til now).
412
Cheap and nasty PowerShell alternative :D

2019-10-14 17_58_15-Refile.png

Run it from the shortcut or a PowerShell console.

Entering a value for Separator overrides Use first x characters.

Disclaimer: Works here ;)

Code: PowerShell [Select]
  1. <# This form was created using POSHGUI.com  a free online gui designer for PowerShell
  2. .NAME
  3.     Refile.ps1
  4. #>
  5.  
  6. Function FileBrowser {
  7.   $objForm = New-Object System.Windows.Forms.FolderBrowserDialog
  8.   $objForm.Description = "Select folder containing files"
  9.   $objForm.SelectedPath = [System.Environment+SpecialFolder]'MyComputer'
  10.   $objForm.ShowNewFolderButton = $false
  11.   $result = $objForm.ShowDialog()
  12.   if ($result -eq "OK") {
  13.     return $objForm.SelectedPath
  14.   } else {
  15.     return ""
  16.   }
  17. }
  18.  
  19. #region begin GUI{
  20.  
  21. Add-Type -AssemblyName System.Windows.Forms
  22. [System.Windows.Forms.Application]::EnableVisualStyles()
  23.  
  24. $Form                            = New-Object system.Windows.Forms.Form
  25. $Form.ClientSize                 = '400,350'
  26. $Form.text                       = "Refile"
  27. $Form.TopMost                    = $false
  28.  
  29. $TextBox1                        = New-Object system.Windows.Forms.TextBox
  30. $TextBox1.multiline              = $false
  31. $TextBox1.width                  = 225
  32. $TextBox1.height                 = 21
  33. $TextBox1.location               = New-Object System.Drawing.Point(85,19)
  34. $TextBox1.Font                   = 'Microsoft Sans Serif,12'
  35.  
  36. $TextBox2                        = New-Object system.Windows.Forms.TextBox
  37. $TextBox2.multiline              = $false
  38. $TextBox2.width                  = 225
  39. $TextBox2.height                 = 21
  40. $TextBox2.location               = New-Object System.Drawing.Point(85,60)
  41. $TextBox2.Font                   = 'Microsoft Sans Serif,12'
  42.  
  43. $Button1                         = New-Object system.Windows.Forms.Button
  44. $Button1.text                    = "..."
  45. $Button1.width                   = 40
  46. $Button1.height                  = 30
  47. $Button1.location                = New-Object System.Drawing.Point(323,17)
  48. $Button1.Font                    = 'Microsoft Sans Serif,12'
  49.  
  50. $Button2                         = New-Object system.Windows.Forms.Button
  51. $Button2.text                    = "..."
  52. $Button2.width                   = 40
  53. $Button2.height                  = 30
  54. $Button2.location                = New-Object System.Drawing.Point(323,58)
  55. $Button2.Font                    = 'Microsoft Sans Serif,12'
  56.  
  57. $Label1                          = New-Object system.Windows.Forms.Label
  58. $Label1.text                     = "Source:"
  59. $Label1.AutoSize                 = $true
  60. $Label1.width                    = 25
  61. $Label1.height                   = 10
  62. $Label1.location                 = New-Object System.Drawing.Point(20,19)
  63. $Label1.Font                     = 'Microsoft Sans Serif,12'
  64.  
  65. $Label2                          = New-Object system.Windows.Forms.Label
  66. $Label2.text                     = "Dest:"
  67. $Label2.AutoSize                 = $true
  68. $Label2.width                    = 25
  69. $Label2.height                   = 10
  70. $Label2.location                 = New-Object System.Drawing.Point(20,59)
  71. $Label2.Font                     = 'Microsoft Sans Serif,12'
  72.  
  73. $ComboBox1                       = New-Object system.Windows.Forms.ComboBox
  74. $ComboBox1.width                 = 80
  75. $ComboBox1.height                = 20
  76. @('1','2','3','4','5') | ForEach-Object {[void] $ComboBox1.Items.Add($_)}
  77. $ComboBox1.location              = New-Object System.Drawing.Point(230,190)
  78. $ComboBox1.Font                  = 'Microsoft Sans Serif,12'
  79.  
  80. $Label3                          = New-Object system.Windows.Forms.Label
  81. $Label3.text                     = "Use first x characters:"
  82. $Label3.AutoSize                 = $true
  83. $Label3.width                    = 25
  84. $Label3.height                   = 10
  85. $Label3.location                 = New-Object System.Drawing.Point(60,193)
  86. $Label3.Font                     = 'Microsoft Sans Serif,12'
  87.  
  88. $Label4                          = New-Object system.Windows.Forms.Label
  89. $Label4.text                     = "or"
  90. $Label4.AutoSize                 = $true
  91. $Label4.width                    = 25
  92. $Label4.height                   = 10
  93. $Label4.location                 = New-Object System.Drawing.Point(188,160)
  94. $Label4.Font                     = 'Microsoft Sans Serif,12'
  95.  
  96. $TextBox3                        = New-Object system.Windows.Forms.TextBox
  97. $TextBox3.multiline              = $false
  98. $TextBox3.width                  = 80
  99. $TextBox3.height                 = 20
  100. $TextBox3.Text                   = ''
  101. $TextBox3.location               = New-Object System.Drawing.Point(230,130)
  102. $TextBox3.Font                   = 'Microsoft Sans Serif,12'
  103.  
  104. $TextBox4                        = New-Object system.Windows.Forms.TextBox
  105. $TextBox4.multiline              = $false
  106. $TextBox4.width                  = 80
  107. $TextBox4.height                 = 20
  108. $TextBox4.Text                   = 'txt'
  109. $TextBox4.location               = New-Object System.Drawing.Point(230,95)
  110. $TextBox4.Font                   = 'Microsoft Sans Serif,12'
  111.  
  112. $Label5                          = New-Object system.Windows.Forms.Label
  113. $Label5.text                     = "Separator (eg. -):"
  114. $Label5.AutoSize                 = $true
  115. $Label5.width                    = 25
  116. $Label5.height                   = 10
  117. $Label5.location                 = New-Object System.Drawing.Point(60,130)
  118. $Label5.Font                     = 'Microsoft Sans Serif,12'
  119.  
  120. $Label6                          = New-Object system.Windows.Forms.Label
  121. $Label6.text                     = "Extension (eg. pdf):"
  122. $Label6.AutoSize                 = $true
  123. $Label6.width                    = 25
  124. $Label6.height                   = 10
  125. $Label6.location                 = New-Object System.Drawing.Point(60,95)
  126. $Label6.Font                     = 'Microsoft Sans Serif,12'
  127.  
  128. $Button3                         = New-Object system.Windows.Forms.Button
  129. $Button3.text                    = "Go"
  130. $Button3.width                   = 60
  131. $Button3.height                  = 30
  132. $Button3.location                = New-Object System.Drawing.Point(165,240)
  133. $Button3.Font                    = 'Microsoft Sans Serif,12'
  134.  
  135. $Button4                         = New-Object system.Windows.Forms.Button
  136. $Button4.text                    = "Create 50 test files in Source"
  137. $Button4.width                   = 140
  138. $Button4.height                  = 50
  139. $Button4.location                = New-Object System.Drawing.Point(120,285)
  140. $Button4.Font                    = 'Microsoft Sans Serif,10'
  141. $Form.controls.AddRange(@($TextBox1,$TextBox2,$Button1,$Button2,$Label1,$Label2,$ComboBox1,$Label3,$Label4,$TextBox3,$Label5,$Button3,$Button4,$TextBox4,$Label6))
  142.  
  143. $Button1.Add_Click({
  144.   $TextBox1.Text = (FileBrowser)
  145. })
  146.  
  147. $Button2.Add_Click({
  148.   $TextBox2.Text = (FileBrowser)
  149. })
  150.  
  151. $Button3.Add_Click({
  152.   if (!(($TextBox1.Text -eq '') -and ($TextBox2.Text -eq ''))) {
  153.     $dest = $TextBox2.Text
  154.     $files = Get-ChildItem "$($TextBox1.Text)\*.$($TextBox4.Text)" -File
  155.  
  156.     for ($i = 0; $i -lt $files.Count; $i++) {
  157.       $folder = $null
  158.       if ($TextBox3.Text -eq '') {
  159.         $folder = (Split-Path -Leaf $files[$i]).Substring(0, $ComboBox1.SelectedItem).Trim()
  160.       } else {
  161.         $sep = (Split-Path -Leaf $files[$i]).IndexOf($TextBox3.Text)
  162.           switch ($sep) {
  163.             -1 {continue}
  164.             0  {$folder = (Split-Path -Leaf $files[$i]).Substring(0, 1).Trim()
  165.               break
  166.              }
  167.           default {$folder = (Split-Path -Leaf $files[$i]).Substring(0, $sep).Trim()}
  168.         }
  169.       }
  170.       if ($folder -ne $null) {
  171.         if (!(Test-Path "$($dest)\$($folder)")) {
  172.           New-Item -ItemType Directory "$($dest)\$($folder)"
  173.         }
  174.         Move-Item $files[$i] "$($dest)\$($folder)\$((Split-Path -Leaf $files[$i]))"
  175.       }
  176.     }
  177.   }
  178. })
  179.  
  180. $Button4.Add_Click({
  181.   if (!($TextBox1.Text -eq '')) {
  182. # Set the initial value to control the do loop
  183.     $seed = 0
  184. # How many files should be generated
  185.     $random = 50
  186. # File size in bytes
  187.     $ranSize = 4096
  188. # Path where the file will be created
  189.     $ranPath = "$($TextBox1.Text)\"
  190.     do {
  191.       $netFn = [System.IO.Path]::GetRandomFileName()
  192.       $netfn = [System.IO.Path]::ChangeExtension($netFn, $TextBox4.Text)
  193.       fsutil file createnew $ranPath$netFn $ranSize
  194.       $seed++
  195.     } until ($seed -eq $random)
  196.   }
  197. })
  198.  
  199. #endregion events }
  200.  
  201. #endregion GUI }
  202.  
  203. #Write your logic code here
  204.  
  205. [void]$Form.ShowDialog()
413
Living Room / Re: Android annoyances
« Last post by 4wd on October 11, 2019, 02:16 AM »
1) I very often accidentally switch on the Google Assistant, how do I completely disable or uninstall it? I don't find any value in using it and it has some very basic shortcuts that interfere too often.

Given that there are numerous phones with possibly multiple ways of invoking Assistant perhaps it might not have occurred to you that you telling us how you accidentally keep invoking it might help us to have relevant suggestions on how not to do it.

Like not holding your finger on the fingerprint sensor too long ...

hmmmm ...
414
Living Room / Re: Free call recorder for Android
« Last post by 4wd on September 17, 2019, 03:11 PM »
@Iainb: There's a few links on the web about it, Google apparently removed it as of Android 6 but manufacturers found ways around it.
With Android 9 they really locked it down to the point where if you want to do call recording then you're probably going to need root, (or alternative firmware, eg. Lineage, etc).

The problem was that different countries have different laws regarding call recording, (eg. UK only requires one of participating parties, Germany requires both parties to give permission), so they took the only reasonable option and disabled it.

NOTE: This is all w.r.t. stock Android.
415
Living Room / Re: Free call recorder for Android
« Last post by 4wd on September 15, 2019, 06:50 PM »
He's got a Moto G7 Power, they run, (for all intents), stock Android - in his case, v9.

I run an automatic call recorder on my Moto G5+, works fine however it's reviews are full of "doesn't record anything" because they're using it on phones running Android 9, (usually a Samsung 9 or 10 in the reviews).

Nothing stopping him from trying any and all of them ... just thought I'd mention that the underlying OS interface to do it no longer exists.
416
Living Room / Re: Free call recorder for Android
« Last post by 4wd on September 13, 2019, 09:36 PM »
The API required was completely removed in Android 9 and as Motorola is pretty much stock Android you're probably out of luck.
417
General Software Discussion / Re: What Android Apps Do You Use?
« Last post by 4wd on September 06, 2019, 06:35 AM »
NewPipe - free lightweight YouTube client.

NewPipe has been created with the purpose of getting the original YouTube experience on your smartphone without annoying ads and questionable permissions.

Aurora Droid

An alternative to the default F-Droid app with an intuitive UI and multiple great features, such as

  • Many repos listed and can be enabled
  • Beautiful design - Follows latest Material Design guidelines
  • Powerful download manager - Pause, resume and retry downloading apps
  • Previous releases - Enables downloading old releases
  • Lists architectures (arm, arm64 ...) and minimal Android versions
418
General Software Discussion / Re: Music player that can play 60 second previews
« Last post by 4wd on September 02, 2019, 02:46 AM »
Strange about MPlayer, I literally just downloaded, extracted, used the command on both video and audio files, and it worked.
419
Living Room / Re: Interesting "stuff"
« Last post by 4wd on August 30, 2019, 05:57 AM »
Can this grill-cleaning robot save you stress this summer?

Leave the grill in the Weber, let the bits get carbonised next time, run a wire brush over the grill, cook.

No stress, costs less than $2 every few years (for a new brush, use it for cleaning up welds too) ... all I've done for the last 30 years.
421
Monolith - a data hoarder's dream come true: bundle any web page into a single HTML file:
https://github.com/Y2Z/monolith
This one seems for Linux only. Any similar for Windows available ?

It's written in Rust, you can install and compile on Windows (or even compile it under WSL - Windows Subsystem for Linux) ... try the attached.
422
General Software Discussion / Re: Music player that can play 60 second previews
« Last post by 4wd on August 23, 2019, 03:42 PM »
You could try mplayer if you don't mind the CLI:

Code: Text [Select]
  1. mplayer -endpos 00:01:00 *.mp3
423
General Software Discussion / Re: Gmail to SMS
« Last post by 4wd on August 23, 2019, 03:13 PM »
Addendum: added info for Pushetta notification, (a completely free service).

NOTE: Gotify - Android only client (not likely to be a iOS app due to how app store works)
Pushetta - Android and iOS clients

Original GMail script courtesy the author noted, I've added the few additions for the Gotify notification.  You'd want to loop it, apply your filter, compare last email ID to make sure you're not resending a push notification, and probably tidy it up by putting things in functions, etc but that's all relatively simple.

Code: PowerShell [Select]
  1. #-------------------------------------------------------------------------------
  2. # Name:        get_gmail.ps1
  3. # URL:         http://gallery.technet.microsoft.com/scriptcenter/Get-new-gmail-emails-a0aa3db8
  4. #
  5. # Purpose:     Get new email headers from gmail - read only.
  6. #
  7. # Usage:       Enter username and password the first time which will be saved.
  8. #
  9. # Author:      Amir Hanna
  10. #
  11. # Created:     20/07/2014
  12. # Copyright:   Public domain
  13. # Version:     2
  14. #-------------------------------------------------------------------------------
  15.  
  16. $script_folder = Split-Path $MyInvocation.MyCommand.Path
  17. $username_file = ($script_folder + "\user")
  18. $pass_file = ($script_folder + "\pass")
  19.  
  20. if ( !(Test-Path -LiteralPath $username_file -PathType Leaf) -or !(Test-Path -LiteralPath $pass_file -PathType Leaf) ) {
  21.   Write-Host "Please type a username: "
  22.   Read-Host | Set-Content -LiteralPath $username_file
  23.  
  24.   Write-Host "Please type a password: "
  25.   Read-Host -AsSecureString | ConvertFrom-SecureString > $pass_file
  26. }
  27.  
  28. $username = Get-Content $username_file
  29. $pass = Get-Content $pass_file | ConvertTo-SecureString
  30.  
  31. $credentials = New-Object System.Management.Automation.PsCredential($username, $pass)
  32.  
  33. $webclient = new-object System.Net.WebClient
  34. $webclient.Credentials = $credentials
  35.  
  36. [xml]$xml= $webclient.DownloadString("https://mail.google.com/mail/feed/atom")
  37.  
  38. if (!$xml) { return }
  39.  
  40. Write-Host -BackgroundColor Red -ForegroundColor White "You have", $xml.feed.fullcount, "new emails."
  41.  
  42. $format= @{Expression={[string][System.Math]::Round(((get-date) - (Get-Date $_.issued)).TotalHours, 1) + " hours"};`
  43.          Label="Received since"; Width=20}, @{Expression={$_.author.name}; Label="From"; Width=20},`
  44.          @{Expression={$_.title}; Label="Subject"}, @{Expression={$_.summary}; Label="Summary"}
  45.  
  46. $xml.feed.entry | format-table $format -wrap
  47.  
  48.  
  49. <# ----------------------------- #>
  50. # Added stuff for Gotify/Pushetta Push notification
  51.  
  52. # Copy the latest XML feed entry to a variable
  53. $latestEmail = ($xml.feed.entry | Select-Object -First 1)
  54.  
  55. <#
  56. $xml.feed.entry.author.email
  57. $xml.feed.entry.author.name
  58. $xml.feed.entry.id
  59. $xml.feed.entry.issued
  60. $xml.feed.entry.link
  61. $xml.feed.entry.modified
  62. $xml.feed.entry.summary
  63. $xml.feed.entry.title
  64. #>
  65.  
  66. # Info for Gotify, if $GoToken is null then no Push is sent
  67. $GoToken = ''   # Token obtained from the Gotify server
  68. $GotifyUrl = '' # eg. http://localhost:8080/message
  69.  
  70. if ($GoToken -ne '') {
  71.   $ContentType = "application/json"
  72.   $Method = "POST"
  73.   $JsonMsg = @{
  74.     message = "From: $($latestEmail.author.name), $($latestEmail.author.email)`r`nID: $($latestEmail.id)`r`nIssued: $($latestEmail.issued)`r`nLink: $($latestEmail.link)`r`nModified: $($latestEmail.modified)`r`nSummary: $($latestEmail.summary)`r`nTitle: $($latestEmail.title)";
  75.     priority=2;
  76.     title="$($model)"
  77.   } | ConvertTo-JSON
  78.   $Header = @{}
  79.   $Header.Add("X-Gotify-Key", $GoToken);
  80.   $Header.Add("accept", "application/json");
  81.   $t = Invoke-RestMethod -Method $Method -Uri $GotifyUrl -Header $Header -Body $JsonMsg -ContentType $ContentType
  82. }
  83.  
  84.  
  85. # Info for Pushetta, if $Token is null then no Push is sent
  86. $Token = ''
  87. $Channel = ''
  88.  
  89. if ($Token -ne '') {
  90.   $Uri ='http://api.pushetta.com/api/pushes/' + $Channel + '/'
  91.   $ContentType = "application/json"
  92.   $Method = "POST"
  93.   $JsonMsg = @{
  94.     body = "From: $($latestEmail.author.name), $($latestEmail.author.email)`r`nID: $($latestEmail.id)`r`nIssued: $($latestEmail.issued)`r`nLink: $($latestEmail.link)`r`nModified: $($latestEmail.modified)`r`nSummary: $($latestEmail.summary)`r`nTitle: $($latestEmail.title)";
  95.     message_type ="text/plain"
  96.   } | ConvertTo-JSON
  97.   $Header = @{}
  98.   $Header.Add("AUTHORIZATION", " Token $($Token)")
  99.   $t = Invoke-RestMethod -Method $Method -Uri $Uri -Header $Header -Body $JsonMsg -ContentType $ContentType
  100. }


The notification you'll end up with from the above, (I've blurred things particular to my server/email).
Screenshot_20190823-211553.png
424
General Software Discussion / Re: Gmail to SMS
« Last post by 4wd on August 23, 2019, 06:51 AM »
You can use PowerShell to retrieve your Gmail, filter only those you're interested in and then send a push notification.

I use Gotify as a Push server which keeps it all under my control. They only have an Android client though.

https://github.com/gotify/server

I use Bash and PowerShell scripts that call Gotify when they finish a process.
425
General Software Discussion / Re: Simple php website for hosting files
« Last post by 4wd on August 22, 2019, 05:11 AM »
Not suitable due to your requirement for integrating with WAMP/LAMP but when I've had to quickly do something like this, host files over the web from my computer, then I've always found the simplest to be HTTP File Server (HFS).
Pages: prev1 ... 12 13 14 15 16 [17] 18 19 20 21 22 ... 225next