Last active
July 6, 2024 14:48
-
-
Save maxwellamaral/0204d6e833eb02bd6ba5f8824e6598e4 to your computer and use it in GitHub Desktop.
Alterar diretório no sistema Johnny Decimal no Powershell | Change directory on Johnny Decimal system on Powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cdj { | |
param ( | |
[string]$folderName | |
) | |
# Atualize com a pasta raiz dos seus documentos | |
$rootPath = "D:\Cloud\OneDrive" | |
# Lista de diretórios correspondentes ao padrão | |
$matchingDirs = Get-ChildItem -Path $rootPath -Directory -Recurse | Where-Object { $_.Name -like "*$folderName*" } | |
# Verifica se há correspondências | |
if ($matchingDirs.Count -eq 0) { | |
Write-Host "Nenhum diretório correspondente encontrado para '$folderName'." | |
return | |
} | |
# Se houver apenas uma correspondência, navegue até ela | |
if ($matchingDirs.Count -eq 1) { | |
Set-Location -Path $matchingDirs[0].FullName | |
} else { | |
# Se houver várias correspondências, liste-as | |
Write-Host "Múltiplos diretórios correspondentes encontrados para '$folderName':" | |
$matchingDirs | ForEach-Object { Write-Host $_.FullName } | |
} | |
} |
To run Windows Explorer
function cdem {
param (
[string]$folderName
)
# Atualize com a pasta raiz dos seus documentos
$rootPath = "D:\Cloud\OneDrive"
# Lista de diretórios correspondentes ao padrão
$matchingDirs = Get-ChildItem -Path $rootPath -Directory -Recurse | Where-Object { $_.Name -like "*$folderName*" }
Write-Host "hello"
# Verifica se há correspondências
if ($matchingDirs.Count -eq 0) {
Write-Host "Nenhum diretório correspondente encontrado para '$folderName'."
return
}
# Se houver apenas uma correspondência, navegue até ela
if ($matchingDirs.Count -eq 1) {
Write-Host "$folderName"
explorer.exe $matchingDirs[0].FullName
}
else {
# Se houver várias correspondências, liste-as
Write-Host "Múltiplos diretórios correspondentes encontrados para '$folderName':"
$matchingDirs | ForEach-Object { Write-Host $_.FullName }
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple script for PowerShell