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-Key: 359238

Url: https://administrator.de/contentid/359238

Printed on: April 24, 2024 at 04:04 o'clock

Mitglied: 135051
135051 Dec 26, 2017 updated at 09:39:42 (UTC)
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
Member: joe2017
joe2017 Dec 26, 2017 at 10:09:18 (UTC)
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
Member: colinardo
Solution colinardo Dec 26, 2017 updated at 12:19:13 (UTC)
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
Member: joe2017
joe2017 Dec 28, 2017 at 10:12:28 (UTC)
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!
Member: colinardo
colinardo Dec 28, 2017 at 10:41:39 (UTC)
Goto Top
Kein Thema, ebenfalls guten Rutsch ins nächste Jahr. face-smile
Grüße Uwe