powershell Gerar arquivo base64做diretórioatuale seus filhos

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell Gerar arquivo base64做diretórioatuale seus filhos相关的知识,希望对你有一定的参考价值。

$currentDirectory = [System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition)
Write-host $currentDirectory
$fileNames = [System.IO.Directory]::GetFiles($currentDirectory, "*.*", [System.IO.SearchOption]::AllDirectories)

$unsupportedExtensions = ".ps1", ".base64"

function IsValidFile{
     param([string]$fileName)

    $returnValue = $true
     
    foreach ($unsupportedExtension in $unsupportedExtensions) 
    {
        $isMatch = $fileName.ToLowerInvariant().EndsWith($unsupportedExtension)
        if($isMatch){
            return $false
        }	    
    }
    return $true
}


function GenerateBase64OfFile{
    param([string]$fileName, [string]$extensionToAdd)
    $base64Result = [Convert]::ToBase64String((get-content $fileName -encoding byte))
    [System.String] $extension = [System.IO.Path]::GetExtension($fileName) -replace '\.',""
    

    [System.IO.File]::WriteAllText("$fileName$extensionToAdd", "data:image/$extension;base64,$base64Result")
    return $base64Result
}





foreach ($fileName in $fileNames) {
    if( IsValidFile ($fileName) -eq $true )
    {
        $hash = GenerateBase64OfFile  $fileName ".base64"
        Write-host $fileName
    }
    
 }
 Write-host "#############################################################"
 Write-host "Finalizado Com Sucesso!!!! "
 Write-host "#############################################################"

以上是关于powershell Gerar arquivo base64做diretórioatuale seus filhos的主要内容,如果未能解决你的问题,请参考以下文章

sh Comandos usados para gerar分类

json 1. Gerar dependentdenciasparacriaçãodoprojeto

python Pequeno脚本Python para gerar密钥。

sh Gerar DANFE utilizando https://www.webdanfe.com.br/danfe/index.html

javascript Executar comandos做CMD direto de arquivos JS com o NODE.js e montar arquivos HTML

çar下载de arquivo com PHP