-
-
Save blockspacer/94e215d5b776fd92f02d7c395161b478 to your computer and use it in GitHub Desktop.
| #!/usr/bin/env bash | |
| for file in *; do | |
| if [ -d "$file" ]; then | |
| # Will not run if no directories are available | |
| echo mv "$file" "${file//[ .()@$]/_}" | |
| mv "$file" "${file//[ .()@$]/_}" | |
| fi | |
| done |
| [CmdletBinding()] param () # https://stackoverflow.com/a/69203862 | |
| function Measure-StringDistance { | |
| <# | |
| .SYNOPSIS | |
| Compute the distance between two strings using the Levenshtein distance formula. | |
| .DESCRIPTION | |
| Compute the distance between two strings using the Levenshtein distance formula. | |
| .PARAMETER Source | |
| The source string. | |
| .PARAMETER Compare | |
| The comparison string. | |
| .EXAMPLE | |
| PS C:\> Measure-StringDistance -Source "Michael" -Compare "Micheal" | |
| 2 | |
| There are two characters that are different, "a" and "e". | |
| .EXAMPLE | |
| PS C:\> Measure-StringDistance -Source "Michael" -Compare "Michal" | |
| 1 | |
| There is one character that is different, "e". | |
| .NOTES | |
| Author: | |
| Michael West | |
| #> | |
| [CmdletBinding(SupportsShouldProcess=$true)] | |
| [OutputType([int])] | |
| param ( | |
| [Parameter(ValueFromPipelineByPropertyName=$true)] | |
| [string]$Source = "", | |
| [string]$Compare = "" | |
| ) | |
| $n = $Source.Length; | |
| $m = $Compare.Length; | |
| $d = New-Object 'int[,]' $($n+1),$($m+1) | |
| if ($n -eq 0){ | |
| return $m | |
| } | |
| if ($m -eq 0){ | |
| return $n | |
| } | |
| for ([int]$i = 0; $i -le $n; $i++){ | |
| $d[$i, 0] = $i | |
| } | |
| for ([int]$j = 0; $j -le $m; $j++){ | |
| $d[0, $j] = $j | |
| } | |
| for ([int]$i = 1; $i -le $n; $i++){ | |
| for ([int]$j = 1; $j -le $m; $j++){ | |
| if ($Compare[$($j - 1)] -eq $Source[$($i - 1)]){ | |
| $cost = 0 | |
| } | |
| else{ | |
| $cost = 1 | |
| } | |
| $d[$i, $j] = [Math]::Min([Math]::Min($($d[$($i-1), $j] + 1), $($d[$i, $($j-1)] + 1)),$($d[$($i-1), $($j-1)]+$cost)) | |
| } | |
| } | |
| return $d[$n, $m] | |
| } | |
| function Levenshtein-StringDistance { | |
| [CmdletBinding(SupportsShouldProcess=$true)] | |
| [OutputType([int])] | |
| # get-ld.ps1 (Levenshtein Distance) | |
| # Levenshtein Distance is the # of edits it takes to get from 1 string to another | |
| # This is one way of measuring the "similarity" of 2 strings | |
| # Many useful purposes that can help in determining if 2 strings are similar possibly | |
| # with different punctuation or misspellings/typos. | |
| # | |
| ######################################################## | |
| # Putting this as Source non comment or empty line declares the parameters | |
| # the script accepts | |
| ########### | |
| param([string] $Source, [string] $Compare, [switch] $ignoreCase) | |
| # No NULL check needed, why is that? | |
| # PowerShell parameter handling converts Nulls into empty strings | |
| # so we will never get a NULL string but we may get empty strings(length = 0) | |
| ######################### | |
| $len1 = $Source.length | |
| $len2 = $Compare.length | |
| # If either string has length of zero, the # of edits/distance between them | |
| # is simply the length of the other string | |
| ####################################### | |
| if($len1 -eq 0) | |
| { return $len2 } | |
| if($len2 -eq 0) | |
| { return $len1 } | |
| # make everything lowercase if ignoreCase flag is set | |
| if($ignoreCase -eq $true) | |
| { | |
| $Source = $Source.tolowerinvariant() | |
| $Compare = $Compare.tolowerinvariant() | |
| } | |
| # create 2d Array to store the "distances" | |
| $dist = new-object -type 'int[,]' -arg ($len1+1),($len2+1) | |
| # initialize the Source row and Source column which represent the 2 | |
| # strings we're comparing | |
| for($i = 0; $i -le $len1; $i++) | |
| { $dist[$i,0] = $i } | |
| for($j = 0; $j -le $len2; $j++) | |
| { $dist[0,$j] = $j } | |
| $cost = 0 | |
| for($i = 1; $i -le $len1;$i++) | |
| { | |
| for($j = 1; $j -le $len2;$j++) | |
| { | |
| if($Compare[$j-1] -ceq $Source[$i-1]) | |
| { | |
| $cost = 0 | |
| } | |
| else | |
| { | |
| $cost = 1 | |
| } | |
| # The value going into the cell is the min of 3 possibilities: | |
| # 1. The cell immediately above plus 1 | |
| # 2. The cell immediately to the left plus 1 | |
| # 3. The cell diagonally above and to the left plus the 'cost' | |
| ############## | |
| # I had to add lots of parentheses to "help" the Powershell parser | |
| # And I separated out the tempmin variable for readability | |
| $tempmin = [System.Math]::Min(([int]$dist[($i-1),$j]+1) , ([int]$dist[$i,($j-1)]+1)) | |
| $dist[$i,$j] = [System.Math]::Min($tempmin, ([int]$dist[($i-1),($j-1)] + $cost)) | |
| } | |
| } | |
| # the actual distance is stored in the bottom right cell | |
| return $dist[$len1, $len2]; | |
| } | |
| # https://dejanstojanovic.net/powershell/2018/february/merge-folders-with-windows-powershell-script/ | |
| function MergeDirsByDiff | |
| { | |
| [CmdletBinding(SupportsShouldProcess=$true)] | |
| Param( | |
| [Parameter(Mandatory=$true)] | |
| [string]$sourcePath, | |
| [Parameter(Mandatory=$true)] | |
| [string]$destinationPath, | |
| [switch] $Recurse | |
| ) | |
| # https://www.sqlhammer.com/compare-paths-with-powershell/ | |
| $sourcePath = Join-Path "$sourcePath" '' | |
| $destinationPath = Join-Path "$destinationPath" '' | |
| #$files = Get-ChildItem -Path $sourcePath -Recurse -Filter "*" | |
| [System.Collections.ArrayList]$files = @( | |
| #$(Get-ChildItem -LiteralPath $sourcePath -Recurse | sort -Descending) | |
| $(Get-ChildItem -LiteralPath $sourcePath | sort -Descending) | |
| ) | |
| Write-Verbose "MergeDirsByDiff sourcePath=$sourcePath destinationPath=$destinationPath files=$files" | |
| foreach($file in $files){ | |
| $sourcePathFile = $file.FullName | |
| $destinationPathFile = $file.FullName.Replace($sourcePath, $destinationPath) | |
| #sourcePathFile=G:\downloads\test\1\test2test\test2test | |
| #destinationPath=G:\downloads\test\1\test1test\Новый текстовый документ.txt | |
| #destinationPathFile=G:\downloads\test\1\test1test\Новый текстовый документ.txttest2test | |
| $exists = Test-Path $destinationPathFile | |
| $isFile = Test-Path -LiteralPath $sourcePathFile -PathType Leaf | |
| $isFolder = Test-Path -LiteralPath $sourcePathFile -PathType Container | |
| Write-Verbose "MergeDirsByDiff sourcePath=$sourcePath sourcePathFile=$sourcePathFile destinationPath=$destinationPath destinationPathFile=$destinationPathFile file.FullName=$sourcePathFile isFile=$isFile isFolder=$isFolder" | |
| if(!$exists) | |
| { | |
| Write-Verbose "MergeDirsByDiff new path=$destinationPathFile" | |
| $dir = Split-Path -parent $destinationPathFile | |
| if (!(Test-Path($dir))) { | |
| Write-Verbose "MergeDirsByDiff new dir=$dir" | |
| New-Item -ItemType directory -Path $dir -Force -ErrorAction Continue -Verbose | |
| } | |
| if ($isFolder) { # copy folder into new folder that did not exist before | |
| if (!(Test-Path($destinationPathFile))) { | |
| Write-Verbose "MergeDirsByDiff new dir=$dir" | |
| New-Item -ItemType directory -Path $destinationPathFile -Force -ErrorAction Continue -Verbose | |
| } | |
| if ("$sourcePathFile" -eq "$sourcePath") { | |
| throw "infinite recursion! $sourcePathFile == $sourcePath" | |
| } | |
| if ("$destinationPathFile" -eq "$destinationPath") { | |
| throw "infinite recursion! $destinationPathFile == $destinationPath" | |
| } | |
| Write-Host "Merging folder sourcePathFile=$sourcePathFile into destinationPathFile=$destinationPathFile" | |
| MergeDirsByDiff -sourcePath "$sourcePathFile" -destinationPath "$destinationPathFile" -Recurse | |
| #Copy-Item -LiteralPath "$sourcePathFile/*" -Destination "$destinationPathFile" -Recurse -Force -ErrorAction Continue -Verbose | |
| # without -Recurse | |
| #[System.Collections.ArrayList]$toCopy = @( | |
| # $(Get-ChildItem -LiteralPath $sourcePathFile | sort -Descending) | |
| #) | |
| #Write-Host "MergeDirsByDiff toCopy=$toCopy from sourcePathFile=$sourcePathFile to #destinationPathFile=$destinationPathFile" | |
| ## override files and keep directory structure using "Copy-Item" | |
| #$toCopy | Copy-Item -Destination "$destinationPathFile" -Recurse -Force -ErrorAction Continue -Verbose | |
| } | |
| if($isFile){ | |
| Write-Host "MergeDirsByDiff copy file=$sourcePathFile into $destinationPathFile" | |
| Copy-Item -LiteralPath "$sourcePathFile" -Destination $destinationPathFile -Recurse -Force -ErrorAction Continue -Verbose | |
| } | |
| } | |
| else | |
| { | |
| #$destinationPathItem = (Get-Item -LiteralPath "$destinationPathFile") | |
| if($isFile) | |
| { | |
| #$different = Compare-Object -ReferenceObject $(Get-Content $sourcePathFile) -DifferenceObject $(Get-Content $destinationPathFile) | |
| #if(Compare-Object -ReferenceObject $(Get-Content $sourcePathFile) -DifferenceObject $(Get-Content $destinationPathFile)) | |
| #{ | |
| # Write-Verbose "MergeDirsByDiff different file=$destinationPathFile" | |
| # $dir = Split-Path -parent $destinationPathFile | |
| # if (!(Test-Path($dir))) | |
| # { | |
| # New-Item -ItemType directory -Path $dir -Force -ErrorAction Continue -Verbose | |
| # } | |
| # Copy-Item -LiteralPath "$sourcePathFile" -Destination $destinationPathFile -Recurse -Force -ErrorAction Continue -Verbose | |
| #} else { | |
| # Write-Warning "MergeDirsByDiff skip, same diff of file=$destinationPathFile" | |
| #} | |
| Copy-Item -LiteralPath "$sourcePathFile" -Destination $destinationPathFile -Recurse -Force -ErrorAction Continue -Verbose | |
| } | |
| if ($isFolder) { # copy folder into new folder that existed before | |
| if ("$sourcePathFile" -eq "$sourcePath") { | |
| throw "infinite recursion! $sourcePathFile == $sourcePath" | |
| } | |
| if ("$destinationPathFile" -eq "$destinationPath") { | |
| throw "infinite recursion! $destinationPathFile == $destinationPath" | |
| } | |
| Write-Host "Merging folder sourcePathFile=$sourcePathFile into destinationPathFile=$destinationPathFile" | |
| MergeDirsByDiff -sourcePath "$sourcePathFile" -destinationPath "$destinationPathFile" -Recurse | |
| } | |
| } | |
| } | |
| } | |
| #function MergeDirsByDiffRecursion | |
| #{ | |
| # [CmdletBinding(SupportsShouldProcess=$true)] | |
| # Param( | |
| # [Parameter(Mandatory=$true)] | |
| # [string]$sourcePath, | |
| # [Parameter(Mandatory=$true)] | |
| # [string]$destinationPath, | |
| # [switch] $removeEmptyFolders | |
| # ) | |
| # | |
| # # https://www.sqlhammer.com/compare-paths-with-powershell/ | |
| # $sourcePath = Join-Path "$($sourcePath)" '' | |
| # $destinationPath = Join-Path "$($destinationPath)" '' | |
| # | |
| # [System.Collections.ArrayList]$folderStructure = @( | |
| # $(Get-ChildItem -LiteralPath $sourcePath -Directory -Recurse | sort -Descending) | |
| # ) | |
| # Write-Host "MergeDirsByDiffRecursion sourcePath=$sourcePath destinationPath=$destinationPath #folderStructure=$folderStructure" | |
| # | |
| # foreach ($childDirectory in $folderStructure) | |
| # { | |
| # $dest = $childDirectory.FullName.Replace($sourcePath, $destinationPath) | |
| # Write-Host "MergeDirsByDiffRecursion childDirectory=$($childDirectory.FullName) dest=$dest" | |
| # MergeDirsByDiff -sourcePath $($childDirectory.FullName) -destinationPath $dest -Recurse | |
| # } | |
| # MergeDirsByDiff -sourcePath $sourcePath -destinationPath $destinationPath -Recurse | |
| # $currentChildren = Get-ChildItem -Force -LiteralPath $sourcePath -ErrorAction Continue | |
| # if ($removeEmptyFolders -eq $true) | |
| # { | |
| # $isEmpty = $currentChildren -eq $null | |
| # if ($isEmpty) { | |
| # # remove empty folders | |
| # Write-Host "Remove-Item=$sourcePath" | |
| # Remove-Item -Force -LiteralPath $sourcePath | |
| # } | |
| # } | |
| #} | |
| function MergeSimilarSubdirs { | |
| [CmdletBinding(SupportsShouldProcess=$true)] | |
| [OutputType([int])] | |
| param([string] $inputFolder, [string[]] $inDirs) | |
| if ($inDirs.Count -eq 0) { | |
| return 0 | |
| } | |
| $mergedC = 0 | |
| $inputDirs = $inDirs | % { Get-Item -LiteralPath "$_" } | sort | |
| Write-Host "inputDirs=$inputDirs" | |
| for($index = 0; $index -lt $inputDirs.Count - 1; $index++) | |
| { | |
| $curr = $index | |
| $next = $index+1 | |
| $sourceStr = $inputDirs[$curr].Name.ToLower() | |
| $otherStr = $inputDirs[$next].Name.ToLower() | |
| $lenMax = [Math]::Max($sourceStr.length,$otherStr.length) | |
| if ($lenMax -lt 3) { | |
| # skip short names | |
| } else { | |
| $dist = Levenshtein-StringDistance -Source $sourceStr -Compare $otherStr | |
| $diffPct = $dist / $lenMax | |
| Write-Verbose "DeiffEdits=$dist/$lenMax diffPct=$diffPct sourceStr=$sourceStr otherStr=$otherStr sourceStr.length=$($sourceStr.length)" | |
| $reqPct = 0.12 | |
| if ($lenMax -gt 5) { | |
| $reqPct = 0.23 | |
| } | |
| if ($lenMax -gt 20) { | |
| $reqPct = 0.34 | |
| } | |
| if ($diffPct -le $reqPct) { # similar | |
| $mergedC = $mergedC + 1 | |
| Write-Host "Merging similar folder names StringDistance=$dist diffPct=$diffPct sourceStr=$sourceStr otherStr=$otherStr" | |
| # override files and keep directory structure using "Copy-Item" | |
| #Get-ChildItem -Path "$($inputDirs[$next].FullName)/" | Copy-Item -Destination $targetDir -Recurse -Container -Verbose -Force -ErrorAction Continue | |
| # NOTE: Move-Item fails to move folder contents if folder with same name exists in destination, | |
| # so had to use Copy-Item above | |
| #Move-Item -Path "$($inputDirs[$next].FullName)/*" -Destination "$($inputDirs[$curr].FullName)/" -Verbose -Force -ErrorAction Continue -ErrorVariable $moveItemError | |
| MergeDirsByDiff -sourcePath "$($inputDirs[$next].FullName)" -destinationPath "$($inputDirs[$curr].FullName)" -Recurse | |
| #if ($moveItemError) { | |
| # Write-Warning "Warning, failed to move $($inputDirs[$next].FullName)/* into $($inputDirs#[$curr].FullName)/" | |
| #} else { | |
| # Write-Host "removing $($inputDirs[$next].FullName)" | |
| # Remove-Item -Force -LiteralPath "$($inputDirs[$next].FullName)" -Recurse | |
| #} | |
| Write-Host "removing $($inputDirs[$next].FullName)" | |
| Remove-Item -Force -LiteralPath "$($inputDirs[$next].FullName)" -Recurse | |
| #$index = $index + 1 # folder with $next does not exist anymore | |
| # dir does not exist enymore, remove from array | |
| [array] $newInputDirs = $inputDirs | Where { "$($_.FullName)" -ne "$($inputDirs[$next].FullName)" } | sort #| Where-Object { [array]::IndexOf($inputDirs, $_) -ne $next } | |
| # re-run with new array data | |
| $inFolders = $newInputDirs | % { $_.FullName } | sort | |
| MergeSimilarSubdirs -inputFolder $inputFolder -inDirs $inFolders | |
| break | |
| } | |
| } | |
| } | |
| if($mergedC -le 0) { | |
| Write-Host "final inputDirs=$inputDirs" | |
| } | |
| return $mergedC | |
| } | |
| $inputFolder = "$($pwd.Path)" | |
| [System.Collections.ArrayList]$inputDirs = @( | |
| $(Get-ChildItem -Path $inputFolder -Directory) | |
| ) | |
| if ($inputDirs.Count -eq 0) { | |
| exit 0 | |
| } | |
| if (-not (Test-Path -Path $inputFolder -PathType container)) { | |
| throw "'$inputFolder' not found" | |
| } | |
| # NOTE: sort Ascending to move into folder with shorter name | |
| [System.Collections.ArrayList]$inputDirs = @( | |
| $(Get-ChildItem -Path $inputFolder -Directory | sort) | |
| ) | |
| $inFolders = $inputDirs | % { $_.FullName } | sort | |
| #Write-Host "inFolders=$inFolders" | |
| MergeSimilarSubdirs -inputFolder $inputFolder -inDirs $inFolders | |
| #Write-Host "inputDirs=$($inputDirs)" | |
| #exit 0 | |
| #$attempt = 0 | |
| #$attemptsMax = 1#$inputDirs.Count / 2 + 1 | |
| #while ($attempt -lt $attemptsMax) | |
| #{ | |
| # Write-Host "attempt=$attempt attemptsMax=$attemptsMax" | |
| # $attempt = $attempt + 1 | |
| # $mergedC = MergeSimilarSubdirs -inputFolder $inputFolder | |
| # if($mergedC -le 0) { | |
| # break | |
| # } | |
| #} |
| # Set-ItemProperty 'HKLM:\System\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -value 1 | |
| # set-executionpolicy unrestricted | |
| $inputFolder = "$($pwd.Path)" | |
| if (-not (Test-Path -Path $inputFolder -PathType container)) { | |
| throw "'$inputFolder' not found" | |
| } | |
| [System.Collections.ArrayList]$inputFiles = @( | |
| $(Get-ChildItem -Path $inputFolder) | |
| ) | |
| Write-Host "inputFiles=$($inputFiles)" | |
| $filterFolder = 'D:\bitl\s28.bitdl.ir\Compresed\SKILLSHARE\' | |
| if (-not (Test-Path -Path $filterFolder -PathType container)) { | |
| throw "'$filterFolder' not found" | |
| } | |
| [System.Collections.ArrayList]$filterFiles = @( | |
| $(Get-ChildItem -Path $filterFolder) | |
| ) | |
| Write-Host "filterFiles=$($filterFiles)" | |
| $outputFolder = 'D:\bitl\s28.bitdl.ir\Compresed\tmp2\' | |
| If(!(test-path -PathType container $outputFolder)) | |
| { | |
| # You can ignore errors in PowerShell with the | |
| # -ErrorAction SilentlyContinue parameter (you can shorten this to -ea 0). | |
| # stackoverflow.com/questions/47357135/powershell-equivalent-of-linux-mkdir-p | |
| New-Item $outputFolder -ItemType Directory -ea 0 | |
| } | |
| if (-not (Test-Path -Path $outputFolder -PathType container)) { | |
| throw "'$outputFolder' not found" | |
| } | |
| foreach ($infile in $inputFiles) | |
| { | |
| if ($infile.Extension.ToLower().Equals(".ps1")) { | |
| Write-Host "Extension=$($infile.FullName.ToLower())" | |
| continue | |
| } | |
| #If(!(test-path -PathType container $infile)) | |
| #{ | |
| #Write-Host "not folder=$($infile.Name.ToLower())" | |
| #continue | |
| #} | |
| Write-Host "infile=$($infile.Name.ToLower())" | |
| foreach ($filterfile in $filterFiles) | |
| { | |
| if ($filterfile.Extension.ToLower().Equals(".ps1")) { | |
| Write-Host "Extension=$($filterfile.FullName.ToLower())" | |
| continue | |
| } | |
| if ($infile.BaseName.ToLower().Contains("$($filterfile.BaseName.ToLower())")) { | |
| Write-Host "filterfile=$($filterfile.Name.ToLower())" | |
| $destination = "$($outputFolder)$($infile.Name)" | |
| Write-Host "Destination=$($destination)" | |
| Move-Item -Path "$($infile.FullName)" -Destination "$($destination)" -Verbose -Force -ErrorAction Stop | |
| #if ($infile.DirectoryName.Name.ToLower().StartsWith($exclusion.Name.ToLower())) | |
| #{ | |
| # $exclude = $true | |
| #} | |
| } | |
| } | |
| } |
| # Set-ItemProperty 'HKLM:\System\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -value 1 | |
| # set-executionpolicy unrestricted | |
| $inputFolder = "$($pwd.Path)" | |
| if (-not (Test-Path -Path $inputFolder -PathType container)) { | |
| throw "'$inputFolder' not found" | |
| } | |
| [System.Collections.ArrayList]$inputFiles = @( | |
| $(Get-ChildItem -Path $inputFolder) | |
| ) | |
| Write-Host "inputFiles=$($inputFiles)" | |
| # https://stackoverflow.com/questions/28631419/how-to-recursively-remove-all-empty-folders-in-powershell | |
| # A script block (anonymous function) that will remove empty folders | |
| # under a root folder, using tail-recursion to ensure that it only | |
| # walks the folder tree once. -Force is used to be able to process | |
| # hidden files/folders as well. | |
| $tailRecursion = { | |
| param( | |
| $Path | |
| ) | |
| foreach ($childDirectory in Get-ChildItem -Force -LiteralPath $Path -Directory) { | |
| & $tailRecursion -Path $childDirectory.FullName | |
| } | |
| $currentChildren = Get-ChildItem -Force -LiteralPath $Path | |
| $isEmpty = $currentChildren -eq $null | |
| if ($isEmpty) { | |
| Write-Verbose "Removing empty folder at path '${Path}'." -Verbose | |
| Remove-Item -Verbose -Force -LiteralPath $Path | |
| } | |
| } | |
| # 10 is max subfodler depth | |
| for ($i=1; $i -le 10; $i++) { | |
| foreach ($infile in $inputFiles) | |
| { | |
| if ($infile.Extension.ToLower().Equals(".ps1")) { | |
| #Write-Host "Extension=$($infile.FullName.ToLower())" | |
| continue | |
| } | |
| If(!(Test-Path -Path "$($infile.FullName)" -PathType Container)) | |
| { | |
| Write-Host "not folder=$($infile.Name.ToLower())" | |
| continue | |
| } | |
| #Write-Host "infile=$($infile.Name.ToLower())" | |
| [System.Collections.ArrayList]$filterFiles = @( | |
| $(Get-ChildItem -Path $infile) | |
| ) | |
| #Write-Host "filterFiles=$($filterFiles)" | |
| #Please note that you have to use -gt instead of > in your if condition. #PowerShell uses the following comparison operators to compare values and test conditions: | |
| #-eq = equals (==) | |
| #-ne = not equals (!=) | |
| #-lt = less than (<) | |
| #-gt = greater than (>) | |
| #-le = less than or equals (<=) | |
| #-ge = greater than or equals (>=) | |
| #if ($filterFiles.length -gt 2) { | |
| # Write-Host "length -gt 2" | |
| # continue | |
| #} | |
| #$hasAnySubdir = (Get-ChildItem -Force -Directory $infile).Count -gt 0 | |
| $hasNoFiles = !((Get-ChildItem -Force -File $infile).Count -gt 0) | |
| if (($filterFiles.length -gt 2) -And ($hasNoFiles)) { | |
| Write-Host "length -gt 2 & !hasAnyFile" | |
| # skip dirs that consist only of (many) subfolders | |
| continue | |
| } | |
| $hasTwoFiles = (Get-ChildItem -Force -File $infile).Count -gt 1 | |
| if (($filterFiles.length -gt 2) -And ($hasTwoFiles)) { | |
| Write-Host "length -gt 2 & hasTwoFiles" | |
| # skip dirs with >= 2 files | |
| continue | |
| } | |
| foreach ($filterfile in $filterFiles) | |
| { | |
| if (($filterFiles.length -eq 1) -And ($hasNoFiles)) { | |
| if ((Join-Path "$($inputFolder)" '') -ne (Join-Path "$($filterfile.Parent.FullName)" '')) | |
| { | |
| Write-Host "length -gt 2 & !hasAnyFile" | |
| Write-Host "filterfile=$($filterfile.FullName)" | |
| Write-Host "filterfile.Parent=$($filterfile.Parent.FullName)" | |
| # move up subfolder data from dir that consists only of 1 subfolder | |
| Move-Item -Path "$($filterfile.FullName)/*" -Destination "$($filterfile.Parent.FullName)/" -Verbose -Force -ErrorAction Continue | |
| #exit 0 | |
| } | |
| } | |
| if ($filterfile.Extension.ToLower().Equals(".ps1")) { | |
| Write-Host "Extension=$($filterfile.FullName.ToLower())" | |
| continue | |
| } | |
| If(!(Test-Path -Path "$($filterfile.FullName)" -PathType Container)) | |
| { | |
| Write-Host "not folder=$($filterfile.Name.ToLower())" | |
| continue | |
| } | |
| Write-Host "filterfile=$($filterfile.FullName)" | |
| $destination = "$($infile.FullName)/" | |
| Write-Host "Destination=$($destination)" | |
| # -ErrorAction Stop | |
| Move-Item -Path "$($filterfile.FullName)/*" -Destination "$($destination)" -Verbose -Force -ErrorAction Continue | |
| } | |
| } | |
| } | |
| #Please note that you have to use -gt instead of > in your if condition. #PowerShell uses the following comparison operators to compare values and test conditions: | |
| #-eq = equals (==) | |
| #-ne = not equals (!=) | |
| #-lt = less than (<) | |
| #-gt = greater than (>) | |
| #-le = less than or equals (<=) | |
| #-ge = greater than or equals (>=) | |
| if ($inputFolder.Length -gt 3) { | |
| # delete empty folders | |
| # remark that the code also removes the start folder if that winds up empty | |
| & $tailRecursion -Path "$($inputFolder)" | |
| } |
| # Set-ItemProperty 'HKLM:\System\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -value 1 | |
| # set-executionpolicy unrestricted | |
| # https://stackoverflow.com/questions/28631419/how-to-recursively-remove-all-empty-folders-in-powershell | |
| # A script block (anonymous function) that will remove empty folders | |
| # under a root folder, using tail-recursion to ensure that it only | |
| # walks the folder tree once. -Force is used to be able to process | |
| # hidden files/folders as well. | |
| function tailRecursion($Path) | |
| { | |
| foreach ($childDirectory in Get-ChildItem -Force -LiteralPath $Path -ErrorAction SilentlyContinue -Directory) { | |
| tailRecursion -Path $childDirectory.FullName | |
| } | |
| $currentChildren = Get-ChildItem -Force -LiteralPath $Path -ErrorAction SilentlyContinue | |
| $isEmpty = $currentChildren -eq $null | |
| if ($isEmpty) { | |
| #Write-Verbose "Removing empty folder at path '${Path}'." -Verbose | |
| Remove-Item -Force -LiteralPath $Path | |
| } | |
| } | |
| function movelonedirs($inputFolder) | |
| { | |
| [System.Collections.ArrayList]$inputFiles = @( | |
| $(Get-ChildItem -Force -Path $inputFolder -ErrorAction SilentlyContinue) | |
| ) | |
| Write-Host "inputFiles=$inputFiles" | |
| # 10 is max subfodler depth | |
| for ($i=1; $i -le 10; $i++) { | |
| foreach ($infile in $inputFiles) | |
| { | |
| if ($infile.Extension.ToLower().Equals(".ps1")) { | |
| #Write-Host "Extension=$($infile.FullName.ToLower())" | |
| continue | |
| } | |
| If(!(Test-Path -Path "$($infile.FullName)" -PathType Container)) | |
| { | |
| #Write-Host "not folder=$($infile.Name.ToLower())" | |
| continue | |
| } | |
| #Write-Host "infile=$($infile.Name.ToLower())" | |
| [System.Collections.ArrayList]$filterFiles = @( | |
| $(Get-ChildItem -Force -Path $infile -ErrorAction SilentlyContinue) | |
| ) | |
| #Write-Host "filterFiles=$($filterFiles)" | |
| #Please note that you have to use -gt instead of > in your if condition. #PowerShell uses the following comparison operators to compare values and test conditions: | |
| #-eq = equals (==) | |
| #-ne = not equals (!=) | |
| #-lt = less than (<) | |
| #-gt = greater than (>) | |
| #-le = less than or equals (<=) | |
| #-ge = greater than or equals (>=) | |
| #if ($filterFiles.length -gt 2) { | |
| # Write-Host "length -gt 2" | |
| # continue | |
| #} | |
| #$hasAnySubdir = (Get-ChildItem -Force -Directory $infile).Count -gt 0 | |
| $hasNoFiles = !((Get-ChildItem -Force -File $infile -ErrorAction SilentlyContinue).Count -gt 0) | |
| if (($filterFiles.length -gt 2) -And ($hasNoFiles)) { | |
| #Write-Host "length -gt 2 & !hasAnyFile" | |
| # skip dirs that consist only of subfolders | |
| continue | |
| } | |
| $hasTwoFiles = (Get-ChildItem -Force -File $infile -ErrorAction SilentlyContinue).Count -gt 1 | |
| if (($filterFiles.length -gt 2) -And ($hasTwoFiles)) { | |
| #Write-Host "length -gt 2 & hasTwoFiles" | |
| # skip dirs with >= 2 files | |
| continue | |
| } | |
| foreach ($filterfile in $filterFiles) | |
| { | |
| if ($filterfile.Extension.ToLower().Equals(".ps1")) { | |
| #Write-Host "Extension=$($filterfile.FullName.ToLower())" | |
| continue | |
| } | |
| If(!(Test-Path -Path "$($filterfile.FullName)" -PathType Container)) | |
| { | |
| #Write-Host "not folder=$($filterfile.Name.ToLower())" | |
| continue | |
| } | |
| #Write-Host "filterfile=$($filterfile.FullName)" | |
| $destination = "$($infile.FullName)/" | |
| #Write-Host "Destination=$($destination)" | |
| # -ErrorAction Stop | |
| Move-Item -Path "$($filterfile.FullName)/*" -Destination "$destination" -Force -ErrorAction SilentlyContinue #-Verbose | |
| } | |
| } | |
| } | |
| #Please note that you have to use -gt instead of > in your if condition. #PowerShell uses the following comparison operators to compare values and test conditions: | |
| #-eq = equals (==) | |
| #-ne = not equals (!=) | |
| #-lt = less than (<) | |
| #-gt = greater than (>) | |
| #-le = less than or equals (<=) | |
| #-ge = greater than or equals (>=) | |
| if ($inputFolder.Length -gt 3) { | |
| # delete empty folders | |
| # remark that the code also removes the start folder if that winds up empty | |
| tailRecursion -Path "$inputFolder" | |
| } | |
| } | |
| function run7zbypath($arInputFolder, | |
| [string[]]$arInclude, | |
| [string[]]$passwords) | |
| { | |
| write-host "arInputFolder=$arInputFolder" | |
| write-host "arInclude=$arInclude" | |
| write-host "passwords=$passwords" | |
| #$WinRar = "C:\Program Files\WinRAR\WinRAR.exe" | |
| #if (-not (Test-Path -Path $WinRar -PathType Leaf)) { | |
| # throw "file '$WinRar' not found" | |
| #} | |
| #$UnRAR = "C:\Program Files\WinRAR\UnRAR.exe" | |
| #if (-not (Test-Path -Path $UnRAR -PathType Leaf)) { | |
| # throw "file '$UnRAR' not found" | |
| #} | |
| # 7-Zip Extra: standalone console version, 7z DLL, Plugin for Far Manager | |
| $SZexe = "C:\Program Files\7-Zip\7z.exe" | |
| if (-not (Test-Path -Path $SZexe -PathType Leaf)) { | |
| throw "file '$SZexe' not found" | |
| } | |
| $zFiles = Get-ChildItem -Recurse -path $arInputFolder -Include $arInclude -ErrorAction SilentlyContinue | |
| write-host "zFiles=$zFiles" | |
| #exit 0 | |
| foreach ($zFile in $zFiles) | |
| { | |
| $outPutFolder = "$($zFile.DirectoryName)" | |
| Write-Host "arInputFolder=$arInputFolder" | |
| $isFile = Test-Path -LiteralPath $zFile -PathType Leaf | |
| if(!$isFile) | |
| { | |
| Write-Host "not file=$zFile" | |
| continue | |
| } | |
| $zDir = $zFile.Directory.FullName | |
| Write-Host "Directory=$zDir" | |
| $isFolder = Test-Path -LiteralPath $zDir -PathType Container | |
| if(!$isFolder) | |
| { | |
| Write-Host "not folder=$zDir" | |
| continue | |
| } | |
| $outPutSubFolder = "" | |
| # https://www.sqlhammer.com/compare-paths-with-powershell/ | |
| if ((Join-Path "$arInputFolder" '') -eq (Join-Path "$zDir" '')) { | |
| $outPutSubFolder = "$($zFile.BaseName -replace '\.part\d*$')\" | |
| } | |
| #$outPutFolderExtended = $outPutFolder + "\" + $zFile.BaseName | |
| # Use regex to remove the ‘part#’ part. | |
| #https://stackoverflow.com/a/31784829 | |
| $outPutFolderExtended = "$outPutFolder\$($outPutSubFolder.subString(0, [System.Math]::Min(50, $outPutSubFolder.Length)) -replace "\W")" | |
| $exists = Test-Path $outPutFolderExtended | |
| if($exists) | |
| { | |
| Write-Host "will extract into already existing folder=$outPutFolderExtended" | |
| } | |
| #Expand-Archive -Path "$($zFile.FullName)" -DestinationPath $outPutFolderExtended | |
| foreach ($password in $passwords) | |
| { | |
| Write-Host $password | |
| if ($password) { | |
| &$SZexe "t" "$($zFile.FullName)" "-p$password" ; | |
| if (-Not $?) | |
| { | |
| Write-Host "$password is not the password." | |
| } else { | |
| Write-Host "$password is the password." | |
| # Call 7zip. Provide password as an argument. | |
| #&$SZexe x "$($zFile.FullName)" "-o$($outPutFolderExtended)" -y "-p$($password)" ; | |
| $arguments=@("x", """$($zFile.FullName)""", """-o$outPutFolderExtended""", "-y", "-p$password"); | |
| $ex = start-process -NoNewWindow -FilePath """$SZexe""" -ArgumentList $arguments -wait -PassThru; | |
| if( $ex.ExitCode -eq 0) | |
| { | |
| write-host "Extraction successful, deleting $($zFile.FullName)" | |
| #rmdir -Path "$($zFile.FullName)" -Force | |
| Remove-Item -Force -LiteralPath "$($zFile.FullName)" | |
| } else { | |
| Write-Host "Extraction failed with $($ex.ExitCode) of $($zFile.FullName)" | |
| } | |
| if( $outPutSubFolder.Length -ge 0) { | |
| movelonedirs -inputFolder "$outPutFolderExtended" | |
| } | |
| break # password found | |
| } | |
| } else { | |
| #&$SZexe x "$($zFile.FullName)" "-o$($outPutFolderExtended)" -y ; | |
| #if (-Not $?) | |
| #{ | |
| # Write-Host "empty password string failed" | |
| #} else { | |
| # break # password found | |
| #} | |
| $arguments=@("x", """$($zFile.FullName)""", """-o$outPutFolderExtended""", "-y", "-pbitdownload.ir"); | |
| $ex = start-process -NoNewWindow -FilePath """$SZexe""" -ArgumentList $arguments -wait -PassThru; | |
| if( $ex.ExitCode -eq 0) | |
| { | |
| write-host "Extraction successful, deleting $($zFile.FullName)" | |
| #rmdir -Path "$($zFile.FullName)" -Force | |
| Remove-Item -Force -LiteralPath "$($zFile.FullName)" | |
| } else { | |
| Write-Host "empty password string failed" | |
| Write-Host "Extraction failed with $($ex.ExitCode) of $($zFile.FullName)" | |
| } | |
| if( $outPutSubFolder.Length -ge 0) { | |
| movelonedirs -inputFolder "$outPutFolderExtended" | |
| } | |
| break # password found | |
| } | |
| } | |
| } | |
| } | |
| # Last try is no password at all | |
| # NOTE: usually any password will succeed if archive password is empty | |
| $passwords = @("bitdownload.ir", "p30download.com", "bitdownload", "www.p30download.com", "p30download", "www.bitdownload.ir", "bitdownload", "bitdl", "bitdl.ir", "www.bitdl.ir", "@udemyking1", "hide01.ir", "@MDiscordBot", "@redbluehit", "XDJ", "[email protected]", "whocares", "brute force", "dfghgfh", "irlanguage.com", "www.irlanguage.com", "www.irLanguage.com", "www.vatandownload.com", "vatandownload.com", "www.MihanDownload.com", "www.mihandownload.com", "mihandownload.com", "https://dxschool.org", "dxschool.org", "www.dxschool.org", "www.p30forum.com", "p30forum.com", "p30forum", "www.sharewood-zerkalo.com", "sharewood-zerkalo.com", "sharewood", "SW.BAND", "supersliv.biz", "TonyPart4Four", "www.sharewood.biz", "sharewood.biz", "boominfo.ru", "infovirus.biz", "infosklad.org", "www.infosklad.org", "d3G#0N9JO*", "v1H8s38ouj9Sg9Y9rtI", "") | |
| $arInclude = @("*.rar", "*.zip", "*.iso") | |
| #& $run7zbypath -arInputFolder "$($pwd.Path)" -arInclude $arInclude -passwords $passwords | |
| #run7zbypath("$($pwd.Path)", $arInclude, $passwords) | |
| # 3 is max iterations (attempts) | |
| for ($i=1; $i -le 3; $i++) { | |
| run7zbypath -arInputFolder "$($pwd.Path)" -arInclude $arInclude -passwords $passwords | |
| movelonedirs -inputFolder "$($pwd.Path)" | |
| } | |
| # https://igorpuhalo.wordpress.com/2019/08/29/overcoming-long-path-problem-in-powershell/ | |
| #$zFiles = Get-ChildItem -Recurse -path $arInputFolder -Include ("*.zip") -ErrorAction SilentlyContinue | |
| #$rarFiles = Get-ChildItem -Recurse -path $arInputFolder -Include ("*.rar") -ErrorAction SilentlyContinue #, "*.r[0-9]", "*.r[0-9][0-9]", "*.r[0-9][0-9][0-9]") | |
| #$isoFiles = Get-ChildItem -Recurse -path $arInputFolder -Include ("*.iso") -ErrorAction SilentlyContinue | |
| #$password = "bitdownload.ir" | |
| # foreach ($zFile in $zFiles) | |
| # { | |
| # $outPutFolder = "$($zFile.DirectoryName)" | |
| # Write-Host "arInputFolder=$($arInputFolder)" | |
| # Write-Host "Directory=$((get-item $zFile).Directory.FullName)" | |
| # $outPutSubFolder = "" | |
| # # https://www.sqlhammer.com/compare-paths-with-powershell/ | |
| # if ((Join-Path "$($arInputFolder)" '') -eq (Join-Path "$((get-item # $zFile).Directory.FullName)" '')) { | |
| # $outPutSubFolder = "$($zFile.BaseName -replace '\.part\d*$')\" | |
| # } | |
| # #$outPutFolderExtended = $outPutFolder + "\" + $zFile.BaseName | |
| # | |
| # # Use regex to remove the ‘part#’ part. | |
| # $outPutFolderExtended = "$($outPutFolder)\$($outPutSubFolder.subString(0, # [System.Math]::Min(50, $outPutSubFolder.Length)))" | |
| # | |
| # #Expand-Archive -Path "$($zFile.FullName)" -DestinationPath # $outPutFolderExtended | |
| # | |
| # foreach ($password in $passwords) | |
| # { | |
| # Write-Host $password | |
| # if ($password) { | |
| # &$SZexe "t" "$($zFile.FullName)" "-p$($password)" ; | |
| # if (-Not $?) | |
| # { | |
| # Write-Host "$($password) is not the password." | |
| # } else { | |
| # Write-Host "$($password) is the password." | |
| # # Call 7zip. Provide password as an argument. | |
| # #&$SZexe x "$($zFile.FullName)" "-o$($outPutFolderExtended)" # -y "-p$($password)" ; | |
| # $arguments=@("x", """$($zFile.FullName)""", """-o$# ($outPutFolderExtended)""", "-y", "-p$($password)"); | |
| # $ex = start-process -NoNewWindow -FilePath """$SZexe""" # -ArgumentList $arguments -wait -PassThru; | |
| # if( $ex.ExitCode -eq 0) | |
| # { | |
| # write-host "Extraction successful, deleting $($zFile.# FullName)" | |
| # #rmdir -Path "$($zFile.FullName)" -Force | |
| # Remove-Item -Force -LiteralPath "$($zFile.FullName)" | |
| # } else { | |
| # Write-Host "Extraction failed with $($ex.ExitCode) of $# ($zFile.FullName)" | |
| # } | |
| # if( $outPutSubFolder.Length -ge 0) { | |
| # & $movelonedirs -inputFolder "$($outPutFolderExtended)" | |
| # } | |
| # break # password found | |
| # } | |
| # } else { | |
| # #&$SZexe x "$($zFile.FullName)" "-o$($outPutFolderExtended)" -y ; | |
| # #if (-Not $?) | |
| # #{ | |
| # # Write-Host "empty password string failed" | |
| # #} else { | |
| # # break # password found | |
| # #} | |
| # $arguments=@("x", """$($zFile.FullName)""", """-o$# ($outPutFolderExtended)""", "-y", "-pbitdownload.ir"); | |
| # $ex = start-process -NoNewWindow -FilePath """$SZexe""" # -ArgumentList $arguments -wait -PassThru; | |
| # if( $ex.ExitCode -eq 0) | |
| # { | |
| # write-host "Extraction successful, deleting $($zFile.FullName)# " | |
| # #rmdir -Path "$($zFile.FullName)" -Force | |
| # Remove-Item -Force -LiteralPath "$($zFile.FullName)" | |
| # } else { | |
| # Write-Host "empty password string failed" | |
| # Write-Host "Extraction failed with $($ex.ExitCode) of $# ($zFile.FullName)" | |
| # } | |
| # if( $outPutSubFolder.Length -ge 0) { | |
| # & $movelonedirs -inputFolder "$($outPutFolderExtended)" | |
| # } | |
| # break # password found | |
| # } | |
| # } | |
| # } | |
| # | |
| # foreach ($isoFile in $isoFiles) | |
| # { | |
| # $outPutFolder = "$($isoFile.DirectoryName)" | |
| # Write-Host "arInputFolder=$($arInputFolder)" | |
| # Write-Host "Directory=$((get-item $isoFile).Directory.FullName)" | |
| # $outPutSubFolder = "" | |
| # # https://www.sqlhammer.com/compare-paths-with-powershell/ | |
| # if ((Join-Path "$($arInputFolder)" '') -eq (Join-Path "$((get-item # $isoFile).Directory.FullName)" '')) { | |
| # $outPutSubFolder = "$($isoFile.BaseName -replace '\.part\d*$')\" | |
| # } | |
| # #$outPutFolderExtended = $outPutFolder + "\" + $isoFile.BaseName | |
| # | |
| # # Use regex to remove the ‘part#’ part. | |
| # $outPutFolderExtended = "$($outPutFolder)\$($outPutSubFolder.subString(0, # [System.Math]::Min(50, $outPutSubFolder.Length)))" | |
| # | |
| # #Expand-Archive -Path "$($isoFile.FullName)" -DestinationPath # $outPutFolderExtended | |
| # | |
| # foreach ($password in $passwords) | |
| # { | |
| # Write-Host $password | |
| # if ($password) { | |
| # &$SZexe "t" "$($isoFile.FullName)" "-p$($password)" ; | |
| # #&$UnRAR "t" "-p$($password)" "$($isoFile.FullName)" ; | |
| # if (-Not $?) | |
| # { | |
| # Write-Host "$($password) is not the password." | |
| # } else { | |
| # Write-Host "$($password) is the password." | |
| # # Call 7zip. Provide password as an argument. | |
| # #&$SZexe x -tiso "$($isoFile.FullName)" "-o$# ($outPutFolderExtended)" -y "-p$($password)" ; | |
| # #&$UnRAR x -o- "$($isoFile.FullName)" $outPutFolderExtended -y # "-p$($password)" ; | |
| # #&$SZexe x "$($isoFile.FullName)" "-o$($outPutFolderExtended)" # -y "-p$($password)" ; | |
| # $arguments=@("x", """$($isoFile.FullName)""", """-o$# ($outPutFolderExtended)""", "-y", "-p$($password)"); | |
| # $ex = start-process -NoNewWindow -FilePath """$SZexe""" # -ArgumentList $arguments -wait -PassThru; | |
| # if( $ex.ExitCode -eq 0) | |
| # { | |
| # write-host "Extraction successful, deleting $($isoFile.# FullName)" | |
| # #rmdir -Path "$($isoFile.FullName)" -Force | |
| # Remove-Item -Force -LiteralPath "$($isoFile.FullName)" | |
| # } else { | |
| # Write-Host "Extraction failed with $($ex.ExitCode) of $# ($isoFile.FullName)" | |
| # } | |
| # if( $outPutSubFolder.Length -ge 0) { | |
| # & $movelonedirs -inputFolder "$($outPutFolderExtended)" | |
| # } | |
| # break # password found | |
| # } | |
| # } else { | |
| # #&$SZexe x "$($isoFile.FullName)" "-o$($outPutFolderExtended)" -y ; | |
| # $arguments=@("x", """$($isoFile.FullName)""", """-o$# ($outPutFolderExtended)""", "-y", "-pbitdownload.ir"); | |
| # $ex = start-process -NoNewWindow -FilePath """$SZexe""" # -ArgumentList $arguments -wait -PassThru; | |
| # if( $ex.ExitCode -eq 0) | |
| # { | |
| # write-host "Extraction successful, deleting $($isoFile.FullName)# " | |
| # #rmdir -Path "$($isoFile.FullName)" -Force | |
| # Remove-Item -Force -LiteralPath "$($isoFile.FullName)" | |
| # } else { | |
| # Write-Host "Extraction failed with $($ex.ExitCode) of $# ($isoFile.FullName)" | |
| # Write-Host "empty password string failed" | |
| # } | |
| # if( $outPutSubFolder.Length -ge 0) { | |
| # & $movelonedirs -inputFolder "$($outPutFolderExtended)" | |
| # } | |
| # break # password found | |
| # #&$SZexe x -tiso "$($isoFile.FullName)" "-o$($outPutFolderExtended)# " -y ; | |
| # #&$UnRAR x -o- "$($isoFile.FullName)" $outPutFolderExtended -y "-p$# ($password)" ; | |
| # #if (-Not $?) | |
| # #{ | |
| # # Write-Host "empty password string failed" | |
| # #} else { | |
| # # break | |
| # #} | |
| # } | |
| # } | |
| # } | |
| # | |
| # foreach ($rarFile in $rarFiles) | |
| # { | |
| # $outPutFolder = "$($rarFile.DirectoryName)" | |
| # Write-Host "arInputFolder=$($arInputFolder)" | |
| # Write-Host "Directory=$((get-item $rarFile).Directory.FullName)" | |
| # $outPutSubFolder = "" | |
| # # https://www.sqlhammer.com/compare-paths-with-powershell/ | |
| # if ((Join-Path "$($arInputFolder)" '') -eq (Join-Path "$((get-item # $rarFile).Directory.FullName)" '')) { | |
| # $outPutSubFolder = "$($rarFile.BaseName -replace '\.part\d*$')\" | |
| # } | |
| # #$outPutFolderExtended = $outPutFolder + "\" + $rarFile.BaseName | |
| # | |
| # # Use regex to remove the ‘part#’ part. | |
| # $outPutFolderExtended = "$($outPutFolder)\$($outPutSubFolder.subString(0, # [System.Math]::Min(50, $outPutSubFolder.Length)))" | |
| # | |
| # foreach ($password in $passwords) | |
| # { | |
| # if ($password) { | |
| # Write-Host $password | |
| # #&$UnRAR "lb" $($rarFile.FullName) "-p$($password)" -y | |
| # #&$UnRAR "t" "-p$($password)" "$($rarFile.FullName)" ; | |
| # #if (-Not $?) | |
| # #{ | |
| # # Write-Host "$($password) is not the password." | |
| # #} else { | |
| # # Write-Host "$($password) is the password." | |
| # # # UnRAR the files. -y responds Yes to any queries UnRAR may # #have. | |
| # # # https://stackoverflow.com/a/49236517 | |
| # # &$UnRAR x -o- "$($rarFile.FullName)" $outPutFolderExtended -y # #"-p$($password)" ; | |
| # # #&$WinRar x -o- "$($rarFile.FullName)" $outPutFolderExtended # -y "-p$($password)" ; | |
| # # break # password found | |
| # #} | |
| # | |
| # #&$SZexe "t" "$($rarFile.FullName)" "-p$($password)" ; | |
| # &$UnRAR "t" "-p$($password)" "$($rarFile.FullName)" ; | |
| # if (-Not $?) | |
| # { | |
| # Write-Host "$($password) is not the password." | |
| # } else { | |
| # Write-Host "$($password) is the password." | |
| # # Call 7zip. Provide password as an argument. | |
| # #&$SZexe x -tiso "$($rarFile.FullName)" "-o$# ($outPutFolderExtended)" -y "-p$($password)" ; | |
| # #&$UnRAR x -o- "$($rarFile.FullName)" $outPutFolderExtended -y # "-p$($password)" ; | |
| # #&$SZexe x "$($rarFile.FullName)" "-o$($outPutFolderExtended)" # -y "-p$($password)" ; | |
| # # https://www.winrar-france.fr/winrar_instructions_for_use/# source/html/HELPSwitches.htm | |
| # #$arguments=@("x", "-o-", """$($rarFile.FullName)""", """$# ($outPutFolderExtended)""", "-y", "-p$($password)"); | |
| # #$ex = start-process -NoNewWindow -FilePath """$UnRAR""" # -ArgumentList $arguments -wait -PassThru; | |
| # $arguments=@("x", """$($rarFile.FullName)""", """-o$# ($outPutFolderExtended)""", "-y", "-p$($password)"); | |
| # $ex = start-process -NoNewWindow -FilePath """$SZexe""" # -ArgumentList $arguments -wait -PassThru; | |
| # if( $ex.ExitCode -eq 0) | |
| # { | |
| # write-host "Extraction successful, deleting $($rarFile.# FullName)" | |
| # #rmdir -Path "$($rarFile.FullName)" -Force | |
| # Remove-Item -Force -LiteralPath "$($rarFile.FullName)" | |
| # } else { | |
| # Write-Host "Extraction failed with $($ex.ExitCode) of $# ($rarFile.FullName)" | |
| # } | |
| # if( $outPutSubFolder.Length -ge 0) { | |
| # & $movelonedirs -inputFolder "$($outPutFolderExtended)" | |
| # } | |
| # break # password found | |
| # } | |
| # } else { | |
| # #&$UnRAR x -o- "$($rarFile.FullName)" $outPutFolderExtended -y ; | |
| # #if (-Not $?) | |
| # #{ | |
| # # Write-Host "empty password string failed" | |
| # #} else { | |
| # # break # password found | |
| # #} | |
| # | |
| # # https://www.winrar-france.fr/winrar_instructions_for_use/source/# html/HELPSwitches.htm | |
| # #$arguments=@("x", "-o-", """$($rarFile.FullName)""", """$# ($outPutFolderExtended)""", "-y", "-pbitdownload.ir"); | |
| # #$ex = start-process -NoNewWindow -FilePath """$UnRAR""" # -ArgumentList $arguments -wait -PassThru; | |
| # $arguments=@("x", """$($rarFile.FullName)""", """-o$# ($outPutFolderExtended)""", "-y", "-pbitdownload.ir"); | |
| # $ex = start-process -NoNewWindow -FilePath """$SZexe""" # -ArgumentList $arguments -wait -PassThru; | |
| # if( $ex.ExitCode -eq 0) | |
| # { | |
| # write-host "Extraction successful, deleting $($rarFile.FullName)# " | |
| # #rmdir -Path "$($rarFile.FullName)" -Force | |
| # Remove-Item -Force -LiteralPath "$($rarFile.FullName)" | |
| # } else { | |
| # Write-Host "empty password string failed" | |
| # Write-Host "Extraction failed with $($ex.ExitCode) of $# ($rarFile.FullName)" | |
| # } | |
| # if( $outPutSubFolder.Length -ge 0) { | |
| # & $movelonedirs -inputFolder "$($outPutFolderExtended)" | |
| # } | |
| # break # password found | |
| # } | |
| # } | |
| # | |
| # # https://stackoverflow.com/a/33007614 | |
| # # "%ProgramFiles%\WinRAR\UnRAR.exe" x -ad -c- -cfg- -inul -o+ -y "C:\Temp\*.# rar" "C:\Temp\Extracted\" | |
| # | |
| # # Call 7zip. Provide password as an argument. | |
| # #&$SZexe x $rarFile "-o$($outPutFolderExtended)" -y "-p$($password)" ; | |
| # } |
https://stackoverflow.com/a/6246975
git init
git remote add origin <repo_address>
git reset --soft bd43a274a5293bf95bbf1c5bcf75703bd24d
git branch main
git pull origin main
git add .
find . -size +30M -exec git rm --cached {} \;
git commit -m "first commit"
git push --all origin
for dir in ./*/ ; do (cd "$dir" && git add "*.js" && git add "*.cpp" && git add "*.c" && git add "*.cc" && git add "*.cxx" && git add "*.hpp" && git add "*.h" && git add "*.hxx" && git add "*.ipp" && git add "*.md" && git add "*.inl" && git add "*.inc" && git add "*.cs" && git add "*.kt" && git add "*.ts" && git add "*.as3" && git add "*.py" && git add "*.java" && git add "*.glsl" && git add "*.hlsl" && git add "*.frag" && git add "*.vert" && git add "*.cmake" && git add "*.lua" && git add "*.sh" && git add "*.bash" && git add "*.bat" && git add "*.go" && git add "*.rs" && git add "*.rst" && git add "*.jsx" && git add "*.css" && git add "*.scss" && git add "*.pcss" && git add "*.ydb" && git add "*.sql" && git add "*.yaml" && git add "*.yml" && git add "*.xml" && git add "*.pb" && git add "*.fb" && git add "*.ipynb" && git add "*.make" && git add "*.conf" && git add "*.d" && git add "*.ycssjs" && git add "*.doc" && git add "*.docs" && git add "Makefile" && git add "Dockerfile" ); done
for dir in ./*/ ; do (cd "$dir" && git commit -m "first commit" ); done
for dir in ./*/ ; do (cd "$dir" && echo $PWD && git push --all origin ); done
for dir in ./*/ ; do (cd "$dir" && git add . ); done
for dir in ./*/ ; do (cd "$dir" && git commit -m "first commit" ); done
for dir in ./*/ ; do (cd "$dir" && echo $PWD && git push --all origin ); done
Disable Git LFS for a remote https://stackoverflow.com/questions/36626793/disable-git-lfs-for-a-remote
git push --all origin --no-verify
How do I clone all remote branches? https://stackoverflow.com/questions/67699/how-do-i-clone-all-remote-branches
git config --global alias.clone-branches '! git branch -a | sed -n "/\/HEAD /d; /\/master$/d; /remotes/p;" | xargs -L1 git checkout -t'
git clone-branches# install gh https://github.com/cli/cli/blob/trunk/docs/install_linux.md
export gh_userName=blockspacer
export oldpath=`pwd`
gh auth login
git config --global alias.clone-branches '! git branch -a | sed -n "/\/HEAD /d; /\/master$/d; /remotes/p;" | xargs -L1 git checkout -t'
gh repo list $gh_userName --limit 99999 --visibility private --json name --jq ".[]|.name" \
| xargs -i sh -c 'echo "{}" ; gh repo clone "{}" ; echo "$oldpath/{}" ; sleep 1; cd "$oldpath/{}" ; git fetch --all ; git pull --all ; git clone-branches || true ; cd "$oldpath" '
we-141 - delete packing_addr
we-148 - add to 20 produceaddr
bizerba checkway shtrih (but aclas, digi - Michail)
20
30
21 -
24 25
22 23
txt.proc
scales-gm 3.12
17-30
we-141 - delete packing_addr
we-148 - add to 20 produceaddr
bizerba checkway shtrih (but aclas, digi - Michail)
20
30
21 -
24 25
22 23
txt.proc
scales-gm 3.12
17-30
find . -type f -size +30M -printf '%s\t%h/%f\n'
#
# dirs
find . -name ".svn" -type d -exec rm -r {} +
find . -name "il2cppOutput" -type d -exec rm -r {} +
find . -name "IL2CPP" -type d -exec rm -r {} +
find . -name "DevPatchCDN" -type d -exec rm -r {} +
# files
find . -name "MCPrime" -type f -delete
find . -name "transactions.db" -type f -delete
find . -name "ArtifactDB" -type f -delete
find . -name "MCCharon" -type f -delete
find . -name "SourceAssetDB" -type f -delete
find . -name "ispc" -type f -delete
find . -name "LocalisedText.JSON" -type f -delete
# files
find . -name "*.srcaar" -type f -delete
find . -name "*.dat" -type f -delete
find . -name "*.uasset" -type f -delete
find . -name "*.csv" -type f -delete
find . -name "*.pak" -type f -delete
find . -name "*.umap" -type f -delete
find . -name "*.msi" -type f -delete
find . -name "*.bank" -type f -delete
find . -name "*.dsym" -type f -delete
find . -name "*.dylib" -type f -delete
find . -name "*.debug" -type f -delete
find . -name "*.svn-base" -type f -delete
find . -name "*.bak" -type f -delete
find . -name "*.log" -type f -delete
find . -name "*.bin" -type f -delete
find . -name "*.BIN" -type f -delete
find . -name "*.apk" -type f -delete
find . -name "*.asmdef" -type f -delete
find . -name "*.digestcache" -type f -delete
find . -name "*.cache" -type f -delete
find . -name "*.eab" -type f -delete
find . -name "*.dsp" -type f -delete
find . -name "*.dsw" -type f -delete
find . -name "*.eps" -type f -delete
find . -name "*.exr" -type f -delete
find . -name "*.old" -type f -delete
find . -name "*.os4" -type f -delete
find . -name "*.otf" -type f -delete
find . -name "*.u3d" -type f -delete
find . -name "*.bundle" -type f -delete
find . -name "*.catalog" -type f -delete
find . -name "*.sha1" -type f -delete
find . -name "*.bytes" -type f -delete
find . -name "*.prefab" -type f -delete
find . -name "*.pom" -type f -delete
find . -name "*.raw" -type f -delete
find . -name "*.S" -type f -delete
find . -name "*.SIC" -type f -delete
find . -name "*.strings" -type f -delete
find . -name "*.sub" -type f -delete
find . -name "*.sum" -type f -delete
find . -name "*.suo" -type f -delete
find . -name "*.swatch" -type f -delete
find . -name "*.tests" -type f -delete
find . -name "*.TGA" -type f -delete
find . -name "*.tgt" -type f -delete
find . -name "*.unity3d" -type f -delete
find . -name "*.unitypackage" -type f -delete
find . -name "*.wad" -type f -delete
find . -name "*.wpj" -type f -delete
find . -name "*.wrap" -type f -delete
find . -name "*.asset" -type f -delete
find . -name "*.anim" -type f -delete
find . -name "*.aar" -type f -delete
find . -name "*.ac" -type f -delete
find . -name "*.am" -type f -delete
find . -name "*.api" -type f -delete
find . -name "*.bp" -type f -delete
find . -name "*.build" -type f -delete
find . -name "*.buildreport" -type f -delete
find . -name "*.CVS" -type f -delete
find . -name "*.hg" -type f -delete
find . -name "*.idea" -type f -delete
find . -name "*.svn" -type f -delete
find . -name "*.slo" -type f -delete
find . -name "*.lo" -type f -delete
find . -name "*.o" -type f -delete
find . -name "*.obj" -type f -delete
find . -name "*.gch" -type f -delete
find . -name "*.pch" -type f -delete
find . -name "*.so" -type f -delete
find . -name "*.dylib" -type f -delete
find . -name "*.dll" -type f -delete
find . -name "*.wav" -type f -delete
find . -name "*.mp3" -type f -delete
find . -name "*.wma" -type f -delete
find . -name "*.eot" -type f -delete
find . -name "*.ttf" -type f -delete
find . -name "*.woff" -type f -delete
find . -name "*.com" -type f -delete
find . -name "*.class" -type f -delete
find . -name "*.dll" -type f -delete
find . -name "*.exe" -type f -delete
find . -name "*.o" -type f -delete
find . -name "*.so" -type f -delete
find . -name "*.dmg" -type f -delete
find . -name "*.iso" -type f -delete
find . -name "*.jar" -type f -delete
find . -name "*.ttc" -type f -delete
find . -name "*.ttf" -type f -delete
find . -name ".ttf" -type f -delete
find . -name "*.aif" -type f -delete
find . -name "*.aiff" -type f -delete
find . -name "*.it" -type f -delete
find . -name "*.mod" -type f -delete
find . -name "*.mp3" -type f -delete
find . -name "*.ogg" -type f -delete
find . -name "*.s3m" -type f -delete
find . -name "*.wav" -type f -delete
find . -name "*.xm" -type f -delete
find . -name "*.otf" -type f -delete
find . -name "*.ttf" -type f -delete
find . -name "*.bmp" -type f -delete
find . -name "*.exr" -type f -delete
find . -name "*.gif" -type f -delete
find . -name "*.hdr" -type f -delete
find . -name "*.iff" -type f -delete
find . -name "*.jpeg" -type f -delete
find . -name "*.jpg" -type f -delete
find . -name "*.pict" -type f -delete
find . -name "*.png" -type f -delete
find . -name "*.psd" -type f -delete
find . -name "*.tga" -type f -delete
find . -name "*.tif" -type f -delete
find . -name "*.tiff" -type f -delete
find . -name "*.slo" -type f -delete
find . -name "*.lo" -type f -delete
find . -name "*.o" -type f -delete
find . -name "*.obj" -type f -delete
find . -name "*.gch" -type f -delete
find . -name "*.pch" -type f -delete
find . -name "*.so" -type f -delete
find . -name "*.dylib" -type f -delete
find . -name "*.dll" -type f -delete
find . -name "*.mod" -type f -delete
find . -name "*.smod" -type f -delete
find . -name "*.lai" -type f -delete
find . -name "*.la" -type f -delete
find . -name "*.a" -type f -delete
find . -name "*.lib" -type f -delete
find . -name "*.exe" -type f -delete
find . -name "*.out" -type f -delete
find . -name "*.app" -type f -delete
find . -name "*.lo" -type f -delete
find . -name "*.la" -type f -delete
find . -name "*.o" -type f -delete
find . -name "*.loT" -type f -delete
find . -name "luac.out" -type f -delete
find . -name "*.src.rock" -type f -delete
find . -name "*.o" -type f -delete
find . -name "*.os" -type f -delete
find . -name "*.ko" -type f -delete
find . -name "*.obj" -type f -delete
find . -name "*.elf" -type f -delete
find . -name "*.gch" -type f -delete
find . -name "*.pch" -type f -delete
find . -name "*.lib" -type f -delete
find . -name "*.a" -type f -delete
find . -name "*.la" -type f -delete
find . -name "*.lo" -type f -delete
find . -name "*.def" -type f -delete
find . -name "*.exp" -type f -delete
find . -name "*.dll" -type f -delete
find . -name "*.so" -type f -delete
find . -name "*.so.*" -type f -delete
find . -name "*.dylib" -type f -delete
find . -name "*.exe" -type f -delete
find . -name "*.out" -type f -delete
find . -name "*.app" -type f -delete
find . -name "*.i*86" -type f -delete
find . -name "*.x86_64" -type f -delete
find . -name "*.hex" -type f -delete
find . -name "*.slo" -type f -delete
find . -name "*.lo" -type f -delete
find . -name "*.o" -type f -delete
find . -name "*.a" -type f -delete
find . -name "*.la" -type f -delete
find . -name "*.lai" -type f -delete
find . -name "*.so" -type f -delete
find . -name "*.so.*" -type f -delete
find . -name "*.dll" -type f -delete
find . -name "*.dylib" -type f -delete
find . -name "*_i.c" -type f -delete
find . -name "*_p.c" -type f -delete
find . -name "*_h.h" -type f -delete
find . -name "*.ilk" -type f -delete
find . -name "*.meta" -type f -delete
find . -name "*.obj" -type f -delete
find . -name "*.iobj" -type f -delete
find . -name "*.pch" -type f -delete
find . -name "*.pdb" -type f -delete
find . -name "*.ipdb" -type f -delete
find . -name "*.pgc" -type f -delete
find . -name "*.pgd" -type f -delete
find . -name "*.rsp" -type f -delete
find . -name "*.sbr" -type f -delete
find . -name "*.tlb" -type f -delete
find . -name "*.tli" -type f -delete
find . -name "*.tlh" -type f -delete
find . -name "*.tmp" -type f -delete
find . -name "*.tmp_proj" -type f -delete
find . -name "*_wpftmp.csproj" -type f -delete
find . -name "*.vspscc" -type f -delete
find . -name "*.vssscc" -type f -delete
find . -name ".builds" -type f -delete
find . -name "*.pidb" -type f -delete
find . -name "*.svclog" -type f -delete
find . -name "*.scc" -type f -delete
find . -name "*.aps" -type f -delete
find . -name "*.ncb" -type f -delete
find . -name "*.opendb" -type f -delete
find . -name "*.opensdf" -type f -delete
find . -name "*.sdf" -type f -delete
find . -name "*.cachefile" -type f -delete
find . -name "*.VC.db" -type f -delete
find . -name "*.VC.VC.opendb" -type f -delete
find . -name "*.psess" -type f -delete
find . -name "*.vsp" -type f -delete
find . -name "*.vspx" -type f -delete
find . -name "*.sap" -type f -delete
find . -name "*.e2e" -type f -delete
find . -name "*.dmg" -type f -delete
find . -name "*.jar" -type f -delete
unrar l "/hdd4tb/torrents/ReadyOrNot/stage200.rar" > "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt"
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.js$" | cat >> js_files_list.js
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.cpp$" | cat >> cpp_files_list.cpp
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.c$" | cat >> c_files_list.c
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.cc$" | cat >> cc_files_list.cc
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.cxx$" | cat >> cxx_files_list.cxx
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.hpp$" | cat >> hpp_files_list.hpp
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.h$" | cat >> h_files_list.h
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.hxx$" | cat >> hxx_files_list.hxx
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.ipp$" | cat >> ipp_files_list.ipp
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.md$" | cat >> md_files_list.md
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.inl$" | cat >> inl_files_list.inl
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.inc$" | cat >> inc_files_list.inc
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.cs$" | cat >> cs_files_list.cs
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.kt$" | cat >> kt_files_list.kt
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.ts$" | cat >> ts_files_list.ts
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.as3$" | cat >> as3_files_list.as3
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.py$" | cat >> py_files_list.py
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.java$" | cat >> java_files_list.java
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.glsl$" | cat >> glsl_files_list.glsl
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.hlsl$" | cat >> hlsl_files_list.hlsl
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.frag$" | cat >> frag_files_list.frag
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.vert$" | cat >> vert_files_list.vert
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.cmake$" | cat >> cmake_files_list.cmake
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.lua$" | cat >> lua_files_list.lua
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.sh$" | cat >> sh_files_list.sh
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.bash$" | cat >> bash_files_list.bash
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.bat$" | cat >> bat_files_list.bat
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.go$" | cat >> go_files_list.go
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.rs$" | cat >> rs_files_list.rs
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.rst$" | cat >> rst_files_list.rst
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.jsx$" | cat >> jsx_files_list.jsx
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.css$" | cat >> css_files_list.css
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.scss$" | cat >> scss_files_list.scss
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.pcss$" | cat >> pcss_files_list.pcss
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.ydb$" | cat >> ydb_files_list.ydb
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.sql$" | cat >> sql_files_list.sql
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.yaml$" | cat >> yaml_files_list.yaml
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.yml$" | cat >> yml_files_list.yml
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.xml$" | cat >> xml_files_list.xml
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.pb$" | cat >> pb_files_list.pb
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.fb$" | cat >> fb_files_list.fb
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.ipynb$" | cat >> ipynb_files_list.ipynb
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.make$" | cat >> make_files_list.make
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.conf$" | cat >> conf_files_list.conf
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.d$" | cat >> d_files_list.d
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.ycssjs$" | cat >> ycssjs_files_list.ycssjs
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.doc$" | cat >> doc_files_list.doc
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "*\.docs$" | cat >> docs_files_list.docs
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "Makefile$" | cat >> Makefile_files_list.Makefile
cat "/hdd4tb/torrents/ReadyOrNot/inside.stage200.rar.txt" | egrep "Dockerfile$" | cat >> Dockerfile_files_list.Dockerfile
for i in */; do zip -0 -r "${i%/}.zip" "$i" & done; wait
git ls-files -z --others --exclude-standard | tr '\0' '\n' | head -n 50000 | tr '\n' '\0' | xargs -0 -L1 -I '$' git add '$' -v ; git commit -m "first commit" ; git push --all origin --no-verify
OR
git status --porcelain --untracked-files -z | tr '\0' '\n' | grep '??' | awk '{print substr($0, index($0, $2))}' | head -n 50000 | tr '\n' '\0' | xargs -0 -L1 -I '$' git add '$' -v ; git commit -m "first commit" ; git push --all origin --no-verify
readarray -d '' files_array < <(git status --porcelain --untracked-files -z) ; for f in "${files_array[@]}" ; do x=$(echo "$f" | grep '??' | awk '{print substr($0, index($0, $2))}' ) ; echo $x ; y=$(echo "$x" | tr '\n' '\0' | xargs -0 -L1 -I '$' git add '$' -v ) ; echo $y ; done
git ls-files -z --others --exclude-standard | tr '\n' '\0' | xargs -0 -L1 -I '$' git add '$' -v
git status --porcelain --untracked-files | head -n 50000 | grep '??' | awk '{print substr($0, index($0, $2))}' | xargs git add
https://stackoverflow.com/a/15762313
git add $(git ls-files --others --exclude-standard | head -n 50000) ; git commit -m "first commit" ; git push -u origin main
git ls-files --others --exclude-standard | sed "s/^/'/;s/$/'/" | head -n 50000 | xargs git add ; git commit -m "first commit" ; git push -u origin main
infile.txt tail -n +"$X" | head -n "$((Y - X))"
https://unix.stackexchange.com/questions/47407/cat-line-x-to-line-y-on-a-huge-file
find . -size +49M -exec git rm --cached {} \;