Jump to content

Dateinamen Extrahieren bis zum -


Recommended Posts

Hallo ich habe einen Ordner in dem sich mehrere hunderte mp3z befinden. Diese sind wie folgt benannt:

Interpret - Titel.mp3

Ich möchte nun den Interpreten aus dem Dateinamen auslesen Für den Interpreten ein Ordner erstellen. Das Mp3 File dort dann reinverschieben. Also das mit dem Ordner usw bekomme ich ja hin aber das Extrahieren des Interpreten ist mein Problem.

Vielen Dank für die HIlfe!

Link to comment
Share on other sites

I'm not good at german. But here's a bit of example code:

$filename = "Interpret - Titel.mp3"
$array = StringSplit($filename, "-.")
For $x = 1 to $array[0]
    $Output = StringStripWS($array[$x],3)
    MsgBox(0, "Example code: ", $Output)
Next

Your next step would be to understand what each function does, and rewrite this so that it fits your needs.

Link to comment
Share on other sites

Hi,

na da scheint dir ja schon geholfen.

PS: es gibt auch ein gutes Deutsches Forum

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hehe No Problem :geek:

Now here ist the mini Tool to "Organize" the mp3 Files :lmao:

Has anyone a tip to complete the tool? Errors? Bugs? ..?

Thx for help :ph34r:

#include <file.au3>
$filenames = @ScriptDir&"\*.mp3"
$search = FileFindFirstFile($filenames)  

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "Keine Mp3 Dateien gefunden")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    $rdyname = StringSplit($file,"-.")
    $folder = @ScriptDir&"\"&$rdyname[1]
    DirCreate($folder)
    $filesource = @ScriptDir&"\"&$file
    $filemove = @ScriptDir&"\"&$rdyname[1]&"\"&$file
    FileMove($filesource, $filemove)
WEnd

; Close the search handle
FileClose($search)
Edited by quicksilver
Link to comment
Share on other sites

Hm theres a Problem.

He creates the folders. But when he trys to copy the File is a blank in the rdyname variable. And when he trys to Copy the file from $filesource to $filemove the Foldername of the Filemove is Wrong because the Blank is too much.

Eg.

Wrong:

c:\test\Artist - Title.mp3 => c:\test\Artist \Artist - Title.mp3

Right:

c:\test\Artist - Title.mp3 => c:\test\Artist\Artist - Title.mp3

In the Variable $rdyname[1] is a Blank to much :lmao:

Link to comment
Share on other sites

HI,

my try:

#Include <File.au3>

$FileList = _FileListToArray(@ScriptDir, "*.mp3", 1)
If (Not IsArray($FileList)) And (@error = 1) Then
    MsgBox(0, "", "No Files\Folders Found.")
    Exit
EndIf

For $i = 1 To UBound($FileList) - 1
    $r = StringSplit($FileList[$i], " - ")
    DirCreate(@ScriptDir & "\" & $r[1])
    FileMove(@ScriptDir & "\" & $FileList[$i], @ScriptDir & "\" & $r[1])
Next

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hi,

try without the blanks.

#Include <File.au3>

$FileList = _FileListToArray(@ScriptDir, "*.mp3", 1)
If (Not IsArray($FileList)) And (@error = 1) Then
    MsgBox(0, "", "No Files\Folders Found.")
    Exit
EndIf

For $i = 1 To UBound($FileList) - 1
    $r = StringSplit($FileList[$i], "-")
    DirCreate(@ScriptDir & "\" & $r[1])
    FileMove(@ScriptDir & "\" & $FileList[$i], @ScriptDir & "\" & $r[1])
Next

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...