Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Suchen & Ersetzen auf Konsolenebene [solved]
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) Diskussionsforum
View previous topic :: View next topic  
Author Message
Lenz
Veteran
Veteran


Joined: 17 Jul 2003
Posts: 1439
Location: Marburg [HE, D, EU]

PostPosted: Fri Jun 30, 2006 8:55 pm    Post subject: Suchen & Ersetzen auf Konsolenebene [solved] Reply with quote

Hallo,

ich habe für mein Notebook von meinem FLAC-Musikarchiv ein schlankeres Abbild im Ogg-Vorbis-Format erstellt. Soweit alles perfekt, nur steht in den Playlisten noch die Dateiendung der Stücke auf .flac. Da gibt es doch sicherlich eine Möglichkeit, diese automatisiert in .ogg abzuändern, oder? Irgendwie so eine Art Suchen & Ersetzen auf Konsolenebene, ohne jede einzelne Datei in einen Editor laden zu müssen.


Gruß,
Lenz.
_________________
.:: Lenz' Signature 1.7b ::.

| Gentoo Linux since v1.4 (08-2003) [Screenshot]
| NetHack Highscore: 5.476.380 Pts., Val-Dwa-Fem-Law, ~ ascended to demigoddess-hood ~


Last edited by Lenz on Sat Jul 01, 2006 11:06 am; edited 1 time in total
Back to top
View user's profile Send private message
firefly
Watchman
Watchman


Joined: 31 Oct 2002
Posts: 5205

PostPosted: Fri Jun 30, 2006 9:05 pm    Post subject: Reply with quote

das müsste recht einfach mit sed und konsorten gehen.

mit sed müsste das in etwa so aussehen:

Code:
sed "s/.flac/.ogg/g" <dateiname> > <tempdatei>
mv <tempdatei> <dateiname>

_________________
Ein Ring, sie zu knechten, sie alle zu finden,
Ins Dunkel zu treiben und ewig zu binden
Im Lande Mordor, wo die Schatten drohn.
Back to top
View user's profile Send private message
Lenz
Veteran
Veteran


Joined: 17 Jul 2003
Posts: 1439
Location: Marburg [HE, D, EU]

PostPosted: Fri Jun 30, 2006 9:10 pm    Post subject: Reply with quote

Hört sich gut an, nun müsste ich das nur noch so kombinieren, dass er aus /mnt/media/Audio alle .m3u Dateien sucht und diesen Befehl auf diese anwendet.
_________________
.:: Lenz' Signature 1.7b ::.

| Gentoo Linux since v1.4 (08-2003) [Screenshot]
| NetHack Highscore: 5.476.380 Pts., Val-Dwa-Fem-Law, ~ ascended to demigoddess-hood ~
Back to top
View user's profile Send private message
Fabiolla
Apprentice
Apprentice


Joined: 04 Mar 2004
Posts: 277
Location: somewhere

PostPosted: Fri Jun 30, 2006 9:52 pm    Post subject: Reply with quote

Hallo,
könnte folgend funktionieren:

Code:

for file in /mnt/media/Audio/*m3u; do sed -i -e 's/.flac/.ogg/g' $file; done


Mit den Parameter -i ersetzt sed direkt in der Datei -> es muss keine temporäre Datei angelegt werden.
Wenn es in /mnt/media/Audio noch Unterorder gibt könnte man auch eine Kombination mit find | xargs anwenden

lg
Back to top
View user's profile Send private message
Lenz
Veteran
Veteran


Joined: 17 Jul 2003
Posts: 1439
Location: Marburg [HE, D, EU]

PostPosted: Fri Jun 30, 2006 10:09 pm    Post subject: Reply with quote

Ja, in /mnt/media/Audio/ gibt es noch viele Unterordner, Künstler und dann noch jeweilig die Alben.
_________________
.:: Lenz' Signature 1.7b ::.

| Gentoo Linux since v1.4 (08-2003) [Screenshot]
| NetHack Highscore: 5.476.380 Pts., Val-Dwa-Fem-Law, ~ ascended to demigoddess-hood ~
Back to top
View user's profile Send private message
Thargor
Apprentice
Apprentice


Joined: 23 Dec 2005
Posts: 239
Location: Bamberg/Germany

PostPosted: Fri Jun 30, 2006 10:23 pm    Post subject: Reply with quote

und den punkt muss man meines wissens nach escapen, da der sonst für ein beliebiges Zeichen steht
(Korrigiert mich, wenn ich falsch liege)

Also
Code:
for file in /mnt/media/Audio/*m3u; do sed -i -e 's/\.flac/\.ogg/g' $file; done

_________________
Ideas are bulletproof
Back to top
View user's profile Send private message
think4urs11
Bodhisattva
Bodhisattva


Joined: 25 Jun 2003
Posts: 6659
Location: above the cloud

PostPosted: Sat Jul 01, 2006 6:38 am    Post subject: Reply with quote

so sollte das eigentlich gehen:

... gestrichen wg. 'Anforderungen gar nicht bis falsch verstanden'
_________________
Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself


Last edited by think4urs11 on Sat Jul 01, 2006 6:58 am; edited 1 time in total
Back to top
View user's profile Send private message
Thargor
Apprentice
Apprentice


Joined: 23 Dec 2005
Posts: 239
Location: Bamberg/Germany

PostPosted: Sat Jul 01, 2006 6:47 am    Post subject: Re: Suchen & Ersetzen auf Konsolenebene Reply with quote

Würde das nicht alle *.flac in *.ogg verschieben?
Lenz wrote:
... nur steht in den Playlisten noch die Dateiendung der Stücke auf .flac. ...

Gefragt war doch, die Dateinamen in den Playlists zu ändern? (Oder kapier ich dein script bloß nich :?: :D )
_________________
Ideas are bulletproof
Back to top
View user's profile Send private message
think4urs11
Bodhisattva
Bodhisattva


Joined: 25 Jun 2003
Posts: 6659
Location: above the cloud

PostPosted: Sat Jul 01, 2006 6:56 am    Post subject: Reply with quote

öh ja jetzt wo du das so sagst... man sollte eben so früh am morgen noch nicht das Gehirn hochfahren und die Anforderungen dann doch nur halb verstehen.
Hast natürlich recht - hab das schlicht völlig falsch verstanden :oops:

so richtig? (in files je .flac durch .ogg tauschen)
Code:
for i in `find /mnt/media/Audio/ -iname *.m3u | xargs`; do sed -ie 's/\.flac/\.ogg/' $i; done

_________________
Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself
Back to top
View user's profile Send private message
Lenz
Veteran
Veteran


Joined: 17 Jul 2003
Posts: 1439
Location: Marburg [HE, D, EU]

PostPosted: Sat Jul 01, 2006 8:02 am    Post subject: Reply with quote

Das geht schon in die richtige Richtung, nur hat das leider noch Probleme mit Leerzeichen in Datei-/Ordnernamen.
_________________
.:: Lenz' Signature 1.7b ::.

| Gentoo Linux since v1.4 (08-2003) [Screenshot]
| NetHack Highscore: 5.476.380 Pts., Val-Dwa-Fem-Law, ~ ascended to demigoddess-hood ~
Back to top
View user's profile Send private message
Anarcho
Advocate
Advocate


Joined: 06 Jun 2004
Posts: 2970
Location: Germany

PostPosted: Sat Jul 01, 2006 8:35 am    Post subject: Reply with quote

Oh je...warum nicht direkt das richtige Tool nehmen:

Code:
*  sys-apps/rename
      Latest version available: 1.3
      Latest version installed: 1.3
      Size of downloaded files: 81 kB
      Homepage:    http://rename.berlios.de/
      Description: tool for easily renaming files
      License:     GPL-2


Und dann mit dem beiligenden Tool renamexm einfach per Regulären ausdruck die Dateinamen ändern:

Code:
renamexm '-s/.flac/.ogg/' *


mit

Code:
renamexm '-s/.flac/.ogg/' * -t

kannst du nachschauen ob er auch die richtigen Änderungen machen würde. Falls noch Dateien in Unterverzeichnissen liegen: einfach -R noch hinzufügen.
_________________
...it's only Rock'n'Roll, but I like it!
Back to top
View user's profile Send private message
Lenz
Veteran
Veteran


Joined: 17 Jul 2003
Posts: 1439
Location: Marburg [HE, D, EU]

PostPosted: Sat Jul 01, 2006 8:39 am    Post subject: Reply with quote

Weil es nicht um den Dateinamen geht, sondern um den Inhalt der Playlists!
_________________
.:: Lenz' Signature 1.7b ::.

| Gentoo Linux since v1.4 (08-2003) [Screenshot]
| NetHack Highscore: 5.476.380 Pts., Val-Dwa-Fem-Law, ~ ascended to demigoddess-hood ~
Back to top
View user's profile Send private message
think4urs11
Bodhisattva
Bodhisattva


Joined: 25 Jun 2003
Posts: 6659
Location: above the cloud

PostPosted: Sat Jul 01, 2006 8:49 am    Post subject: Reply with quote

*g* Anarcho hat genausowenig ausgeschlafen wie ich ;)

@Lenz: Versuch mal das $i durch "$i" auszutauschen
_________________
Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself
Back to top
View user's profile Send private message
Lenz
Veteran
Veteran


Joined: 17 Jul 2003
Posts: 1439
Location: Marburg [HE, D, EU]

PostPosted: Sat Jul 01, 2006 8:55 am    Post subject: Reply with quote

Das funktioniert leider nicht, wenn ich ein Album habe /Neil Young/Broken Arrow/ kommt das raus:

Code:
sed: kann Arrow/Neil nicht lesen: Datei oder Verzeichnis nicht gefunden
sed: kann Young nicht lesen: Datei oder Verzeichnis nicht gefunden
sed: kann - nicht lesen: Datei oder Verzeichnis nicht gefunden
sed: kann Broken nicht lesen: Datei oder Verzeichnis nicht gefunden
sed: kann Arrow nicht lesen: Datei oder Verzeichnis nicht gefunden

_________________
.:: Lenz' Signature 1.7b ::.

| Gentoo Linux since v1.4 (08-2003) [Screenshot]
| NetHack Highscore: 5.476.380 Pts., Val-Dwa-Fem-Law, ~ ascended to demigoddess-hood ~
Back to top
View user's profile Send private message
Anarcho
Advocate
Advocate


Joined: 06 Jun 2004
Posts: 2970
Location: Germany

PostPosted: Sat Jul 01, 2006 8:59 am    Post subject: Reply with quote

Think4UrS11 wrote:
*g* Anarcho hat genausowenig ausgeschlafen wie ich ;)

@Lenz: Versuch mal das $i durch "$i" auszutauschen


Shit. Hast recht.

Dann lass ich euch mal weiter mit sed rumbasteln... ;)
_________________
...it's only Rock'n'Roll, but I like it!
Back to top
View user's profile Send private message
think4urs11
Bodhisattva
Bodhisattva


Joined: 25 Jun 2003
Posts: 6659
Location: above the cloud

PostPosted: Sat Jul 01, 2006 9:22 am    Post subject: Reply with quote

nu aber (hoffentlich *g*)
Code:
for i in "$(find /mnt/media/Audio/ -iname *.m3u)"; do sed -ie 's/\.flac/\.ogg/' "$(echo $i)"; done

_________________
Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself
Back to top
View user's profile Send private message
Lenz
Veteran
Veteran


Joined: 17 Jul 2003
Posts: 1439
Location: Marburg [HE, D, EU]

PostPosted: Sat Jul 01, 2006 9:51 am    Post subject: Reply with quote

LOL, wie nähern uns dem Ziel, jetzt hat er alle Dateinamen aneinandergereiht und als einen Dateinamen aufgefasst. Fehlermeldung:

Code:
Kann <10 Seiten langer Dateiname> nicht lesen: Der Dateiname ist zu lang

_________________
.:: Lenz' Signature 1.7b ::.

| Gentoo Linux since v1.4 (08-2003) [Screenshot]
| NetHack Highscore: 5.476.380 Pts., Val-Dwa-Fem-Law, ~ ascended to demigoddess-hood ~
Back to top
View user's profile Send private message
think4urs11
Bodhisattva
Bodhisattva


Joined: 25 Jun 2003
Posts: 6659
Location: above the cloud

PostPosted: Sat Jul 01, 2006 10:13 am    Post subject: Reply with quote

Lenz wrote:
LOL, wie nähern uns dem Ziel, jetzt hat er alle Dateinamen aneinandergereiht und als einen Dateinamen aufgefasst.

*hrmpf* jetzt nehm ichs bald persönlich :twisted:
Code:
find /mnt/media/Audio/ -name *.m3u -exec sed -i 's/\.flac/\.ogg/' '{}' \;

die for-Schleife sollte unnötig sein.
_________________
Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself
Back to top
View user's profile Send private message
Lenz
Veteran
Veteran


Joined: 17 Jul 2003
Posts: 1439
Location: Marburg [HE, D, EU]

PostPosted: Sat Jul 01, 2006 10:34 am    Post subject: Reply with quote

Ah, das hat funktioniert! :) Das nenn ich Automatisierung, da hätte ich mit dem Editor ja Tage dran gesessen. Der Befehl kommt sofort in meine Datei "Wichtige UNIX-Befehle". Sed muss ich mir mal genauer anschauen, ich hab noch mehr solche Sachen zu lösen.
_________________
.:: Lenz' Signature 1.7b ::.

| Gentoo Linux since v1.4 (08-2003) [Screenshot]
| NetHack Highscore: 5.476.380 Pts., Val-Dwa-Fem-Law, ~ ascended to demigoddess-hood ~
Back to top
View user's profile Send private message
mrsteven
Veteran
Veteran


Joined: 04 Jul 2003
Posts: 1938

PostPosted: Sat Jul 01, 2006 10:40 am    Post subject: Reply with quote

:arrow: http://www.tty1.net/sed-tutorium/html/index.html
_________________
Unix philosophy: "Do one thing and do it well."
systemd: "Do everything and do it wrong."
Back to top
View user's profile Send private message
Lenz
Veteran
Veteran


Joined: 17 Jul 2003
Posts: 1439
Location: Marburg [HE, D, EU]

PostPosted: Sat Jul 01, 2006 10:42 am    Post subject: Reply with quote

Danke! 8)
_________________
.:: Lenz' Signature 1.7b ::.

| Gentoo Linux since v1.4 (08-2003) [Screenshot]
| NetHack Highscore: 5.476.380 Pts., Val-Dwa-Fem-Law, ~ ascended to demigoddess-hood ~
Back to top
View user's profile Send private message
think4urs11
Bodhisattva
Bodhisattva


Joined: 25 Jun 2003
Posts: 6659
Location: above the cloud

PostPosted: Sat Jul 01, 2006 10:43 am    Post subject: Reply with quote

Lenz wrote:
Ah, das hat funktioniert! :) Das nenn ich Automatisierung, da hätte ich mit dem Editor ja Tage dran gesessen. Der Befehl kommt sofort in meine Datei "Wichtige UNIX-Befehle". Sed muss ich mir mal genauer anschauen, ich hab noch mehr solche Sachen zu lösen.

Sed ist vergleichsweise simpel, ich habe da eher so meine Problemchen mit dem richtigen quoten ala '`"$(\ etc.
und wenn du jetzt noch [solved] an den Titel hängst wär fein :)
_________________
Nothing is secure / Security is always a trade-off with usability / Do not assume anything / Trust no-one, nothing / Paranoia is your friend / Think for yourself
Back to top
View user's profile Send private message
Lenz
Veteran
Veteran


Joined: 17 Jul 2003
Posts: 1439
Location: Marburg [HE, D, EU]

PostPosted: Sat Jul 01, 2006 11:07 am    Post subject: Reply with quote

Okay, und danke für die Bemühungen!
_________________
.:: Lenz' Signature 1.7b ::.

| Gentoo Linux since v1.4 (08-2003) [Screenshot]
| NetHack Highscore: 5.476.380 Pts., Val-Dwa-Fem-Law, ~ ascended to demigoddess-hood ~
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) Diskussionsforum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum