joe2017
Goto Top

Einfügen von Zeichen mit Batch bzw. Powershell

Hallo zusammen,

ich hab ein kleines Problem und müsste dies irgendwie mit einem Script lösen, da ich keine 500 Files durcharbeiten möchte.
Ich hab hier keine Idee wie ich dies lösen könnte und hoffe das irgendjemand ein Tipp oder Script für mich hat.

Am liebsten würde ich dies mit einem Powershell Script erledigen.

Es geht um Gitarren Lieder welche Akkorde beinhalten. Anbei ein Beispiel:
Shadow Of The Day 
Linkin Park





==INTRO==
Em D    C    






==VERSE==
Em            D                C    
 I close both locks below the window
Em            D                C    
 I close both blinds and turn away
Em            D                  C    
 Sometimes solutions aren't so simple  
Em             D               C    
 Sometimes goodbye's the only way  



==CHORUS==
         G A             Em  C    
And the sun will set for you
     G A             Em  C    
The sun will set for you
          G            D   
And the shadow of the day
       Em                   C    
Will embrace the world in grey
         G A             Em  C    
And the sun will set for you



==INSTRUMENTAL==
Em  D    C    



==VERSE==
Em              D                C    
 In cards and flowers on your window
Em                D                  C    
 Your friends all plead for you to stay
Em            D                   C    
 Sometimes beginnings aren't so simple  
Em             D               C    
 Sometimes goodbye's the only way  



==CHORUS==
         G A             Em  C    
And the sun will set for you
     G A             Em  C    
The sun will set for you
          G            D   
And the shadow of the day
       Em                   C    
Will embrace the world in grey
         G A             Em  C    
And the sun will set for you



==INSTRUMENTAL==
Em  D    C     x2

          G            D   
And the shadow of the day
       Em                   C    
Will embrace the world in grey
         G A             Em  C    
And the sun will set for you



==INSTRUMENTAL==
G A     Em  C     x2

          G            D   
And the shadow of the day
       Em                   C    
Will embrace the world in grey
         G A             Em  C     G
And the sun will set for you

In den Zeilen in welchen die Akkorde stehen, muss jetzt leider immer folgendes Zeichen ">" an erster Stelle stehen.
Hier das Beispiel:
Shadow Of The Day 
Linkin Park





==INTRO==
>Em D    C    






==VERSE==
>Em            D                C    
 I close both locks below the window
>Em            D                C    
 I close both blinds and turn away
>Em            D                  C    
 Sometimes solutions aren't so simple  
>Em             D               C    
 Sometimes goodbye's the only way  



==CHORUS==
>        G A             Em  C    
And the sun will set for you
>     G A             Em  C    
The sun will set for you
>          G            D   
And the shadow of the day
>       Em                   C    
Will embrace the world in grey
>         G A             Em  C    
And the sun will set for you

USW. Das muss ich in allen TXT Dateien eines Ordners durchführen.

Wäre über eure Hilfe SEHR dankbar! face-smile

Content-ID: 359238

Url: https://administrator.de/forum/einfuegen-von-zeichen-mit-batch-bzw-powershell-359238.html

Ausgedruckt am: 09.04.2025 um 17:04 Uhr

135051
135051 26.12.2017 aktualisiert um 10:39:42 Uhr
Goto Top
Moin.
Wenn du uns alle deine "eigenen Abkürzungen" der Akkorde auflistest die du verwendest kann man dir helfen face-wink, denn die sind hier nötig um zwischen den Zeilen unterscheiden zu können.
Die gängigen Bezeichnungen können nämlich ganz unterschiedlich ausfallen!
https://www.gitarrenakkorde.org/gitarre-lernen/gitarrenakkorde-uebersich ...

Gruß squash
joe2017
joe2017 26.12.2017 um 11:09:18 Uhr
Goto Top
Hallo squash,

wenn du meine einzelnen Akkorde meinst so wären das diese:

C
D
Dm
E
Em
G
Gm
A
Am
F
Fm
usw.

Diese liste kann ich ja dann beliebig erweitern. Aber nehmen wir zu Beginn einfach erst einmal diese hier. face-wink
colinardo
Lösung colinardo 26.12.2017 aktualisiert um 13:19:13 Uhr
Goto Top
Servus @adm2015 ,
here you go
gci 'D:\Daten' -Filter *.txt -File | %{(gc $_.Fullname) -creplace '^(\s*\b(C|D|Dm|E|Em|G|Gm|A|Am|F|Fm)\b\s*){1,}$','>$0' | sc $_.Fullname}  
Liste der Akkorde im Regex-Pattern, Pfad und Dateierweiterung entsprechend anpassen. Nur die Zeilen in denen wirklich nur diese vorkommen werden mit dem Prefix versehen!

Frohe Weihnachten und gutes Neues.
Grüße Uwe
joe2017
joe2017 28.12.2017 um 11:12:28 Uhr
Goto Top
Hallo colinardo

Vielen Dank!!! Hat bestens funktioniert! Bin leider erst heute dazu gekommen...

Weihnachten eben face-wink
Wünsch euch allen ein guten Start ins neue Jahr!
colinardo
colinardo 28.12.2017 um 11:41:39 Uhr
Goto Top
Kein Thema, ebenfalls guten Rutsch ins nächste Jahr. face-smile
Grüße Uwe