IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Scripts/Batch Discussion :

coller multiple ligne [Batch]


Sujet :

Scripts/Batch

  1. #1
    Membre actif
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2018
    Messages
    274
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Janvier 2018
    Messages : 274
    Points : 237
    Points
    237
    Par défaut coller multiple ligne
    Bonjour,

    j'aimerai savoir, es ce que c'est possible de coller texte ascii avec multiple ligne dans batch c'est pour éviter de créer a chaque fois un fichier texte.
    exemple :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    set /p arq="Coller le texte ascii ici : "
    le texte à copier : http://patorjk.com/software/taag/#p=...ation%0A%0A%0A

    merci d'avance

  2. #2
    Expert confirmé

    Homme Profil pro
    Responsable déploiement (SCCM, InTune, GPO)
    Inscrit en
    Juillet 2014
    Messages
    3 184
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 45
    Localisation : France, Seine Saint Denis (Île de France)

    Informations professionnelles :
    Activité : Responsable déploiement (SCCM, InTune, GPO)
    Secteur : Transports

    Informations forums :
    Inscription : Juillet 2014
    Messages : 3 184
    Points : 5 755
    Points
    5 755
    Par défaut
    Si j'ai bien compris c'est pour générer du code que tu utiliseras dans un batch.
    Ce générateur n'a pas forcement besoin d'être en batch

    Voici en 1 ligne PowerShell.
    - Tu copie ton code Ascii Art dans le presse-papier
    - Tu lance cette ligne PowerShell
    - Le code généré est remplacé dans ton presse-papier

    Code powershell : Sélectionner tout - Visualiser dans une fenêtre à part
    (Get-Clipboard) -replace '([\^&<>\|\(\)!])', '^$1' -replace "%", "%%" -replace '^', 'echo ' | Set-Clipboard

    PS : Faut arrêter avec le batch
    (PowerShell) (batch)

  3. #3
    Expert éminent
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 839
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 839
    Points : 9 222
    Points
    9 222
    Par défaut

    Vous pouvez exécuter le code de Ericlm128 avec un Batch pour générer un autre fichier batch avec le code ART ASCII généré

    Code BATCH : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    <# : batch script Don't Delete This Line. Ne supprimez pas cette ligne.
    @rem # La ligne précédente ne fait rien dans Batch, mais commence un bloc de commentaire multiligne dans PowerShell. Cela permet à un seul script d'être exécuté par les deux interpréteurs.
    @rem # The previous line does nothing in Batch, but begins a multiline comment block in PowerShell. This allows a single script to be executed by both interpreters.
    @echo off
    Title Get ClipBoard And Replace Special Characters for ASCII ART to copy into a batch file
    setlocal
    cd "%~dp0"
    Color 0B & echo(
    echo @echo off ^& Title Copying ART ASCII From ClipBoard to a batch file ^& Color 0A>Code_ART_ASCII.bat
    Echo( Please Wait a while ... Executing the Powershell command ...
    Powershell -executionpolicy remotesigned -Command "Invoke-Expression $([System.IO.File]::ReadAllText('%~f0'))"
    echo pause>>Code_ART_ASCII.bat
    EndLocal
    goto:eof 
    #>
    # here write your powershell commands...
    (Get-Clipboard) -replace '([\^&<>\|\(\)!])', '^$1' -replace "%", "%%" -replace '^', "echo/ " | Out-File Code_ART_ASCII.bat -Append -Encoding ASCII

  4. #4
    Membre actif
    Homme Profil pro
    Étudiant
    Inscrit en
    Janvier 2018
    Messages
    274
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Janvier 2018
    Messages : 274
    Points : 237
    Points
    237
    Par défaut
    Bonjour hackoofr et ericlm128,

    encore un fois un grand merci de votre soutien à mon problème. mille merci

  5. #5
    Expert éminent
    Avatar de hackoofr
    Homme Profil pro
    Enseignant
    Inscrit en
    Juin 2009
    Messages
    3 839
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 48
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Juin 2009
    Messages : 3 839
    Points : 9 222
    Points
    9 222
    Par défaut GetFunky_ASCII_ART_Colors.bat

    Je sais que cette discussion est mais juste je veux partager quelque chose pour savoir comment coloriser cet ASCII ART avec un code hybrid Batch et Powershell :
    Donc vous avez juste à modifier avec un copier et coller votre ASCII ART entre cette variable en powershell :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    $text = @"
    
    
      ___          __                                 _    _               
     |_ _| _ __   / _|  ___   _ __  _ __ ___    __ _ | |_ (_)  ___   _ __  
      | | | '_ \ | |_  / _ \ | '__|| '_ ` _ \  / _` || __|| | / _ \ | '_ \ 
      | | | | | ||  _|| (_) || |   | | | | | || (_| || |_ | || (_) || | | |
     |___||_| |_||_|   \___/ |_|   |_| |_| |_| \__,_| \__||_| \___/ |_| |_|
                                                                           
    
    
    "@
    Le code Batch en question est : GetFunky_ASCII_ART_Colors.bat

    Code BATCH : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    <# : batch script Don't Delete This Line.
    @rem # The previous line does nothing in Batch, but begins a multiline comment block in PowerShell. This allows a single script to be executed by both interpreters.
    @echo off
    Title Get Funky ASCII ART with Colors
    setlocal
    cd "%~dp0"
    Color 0B & echo(
    Echo( This ASCII ART is interpreted with powershell command
    Powershell -executionpolicy remotesigned -Command "Invoke-Expression $([System.IO.File]::ReadAllText('%~f0'))"
    EndLocal
    pause
    @rem # Here you can put other Commands in batch
    cls & Echo( Those are another commands with Batch like ping and ipconfig /all and so on ....
    Timeout /T 1 /NoBreak>nul
    Ping www.google.com
    echo( & Ipconfig /all & pause
    goto:eof 
    #>
    # here write your powershell commands...
    # https://stackoverflow.com/a/35022366/3080770
    function Get-Funky{
        param([string]$Text)
     
        # Use a random colour for each character
        $Text.ToCharArray() | ForEach-Object{
            switch -Regex ($_){
                # Ignore new line characters
                "`r"{
                    break
                }
                # Start a new line
                "`n"{
                    Write-Host " ";break
                }
                # Use random colours for displaying this non-space character
                "[^ ]"{
                    # Splat the colours to write-host
                    $writeHostOptions = @{
                        ForegroundColor = ([system.enum]::GetValues([system.consolecolor])) | get-random
                        # BackgroundColor = ([system.enum]::GetValues([system.consolecolor])) | get-random
                        NoNewLine = $true
                    }
                    Write-Host $_ @writeHostOptions
                    break
                }
                " "{Write-Host " " -NoNewline}
     
            } 
        }
    }
     
     
    $text = @"
     
     
      ___          __                                 _    _               
     |_ _| _ __   / _|  ___   _ __  _ __ ___    __ _ | |_ (_)  ___   _ __  
      | | | '_ \ | |_  / _ \ | '__|| '_ ` _ \  / _` || __|| | / _ \ | '_ \ 
      | | | | | ||  _|| (_) || |   | | | | | || (_| || |_ | || (_) || | | |
     |___||_| |_||_|   \___/ |_|   |_| |_| |_| \__,_| \__||_| \___/ |_| |_|
     
     
     
    "@
    $text # You can delete or comment this line in order to show only the colorized ASCII ART
    Get-Funky $text

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Insertion de multiples lignes.
    Par ludvax dans le forum Oracle
    Réponses: 22
    Dernier message: 11/01/2010, 13h34
  2. [VBA-E] Copier et coller une ligne entiere
    Par DonKnacki dans le forum Macros et VBA Excel
    Réponses: 13
    Dernier message: 30/05/2006, 15h51
  3. insertion avec multiples lignes
    Par f066457 dans le forum Langage SQL
    Réponses: 9
    Dernier message: 27/03/2006, 23h52
  4. Multiplication ligne à ligne uniquement en SQL
    Par mehdou dans le forum Langage SQL
    Réponses: 4
    Dernier message: 13/09/2004, 16h46
  5. Copier Coller une ligne d'une table avec modif ?
    Par nolan76 dans le forum Requêtes
    Réponses: 4
    Dernier message: 04/03/2004, 16h34

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo