PLS,M3U,MPCPL Playliste mit Powershell erstellen

Hallo mal wieder,

heute gibt es was zum programmieren:
Hattet ihr es auch schon öfters, dass Ihr mehrere Ordner habt und für jeden Ordner eine Playliste automatisch erstellen möchtet?

Dann  habe ich vielleicht das richtige für euch.
Ich habe ein kleines Powershell Script welches für jeden Ordner unterhalb eines Root-Ordners eine MPCPL, PLS oder M3U Playliste anlegt und in diese Dateien mit bestimmten Endungen aufnimmt.

Natürlich bleibt es euch frei dies zu bearbeiten – falls es dann doch mal Probleme geben sollte.
Hoffe es hilft euch.

Hier nun das Script: – Speichert es als .ps1 Datei und gibt die 4 gleich genannten Parameter mit

# Parameters for Script
	## -source : The Subfolders of the source path will be checked for MediaFiles (recursivly)
	## -destination : Specify the path where to save the Playlists - Each subfolder gets a Playlist-File with the folder name
	## -playlisttype : MPCPL, PLS OR M3U
	## -filetypes : Which files should be in the playlist - Seperate multiple by ","
	param([string]$source = "\\server\share",[string]$destination = "\\server\share\PLS",[string]$playlisttype = "mpcpl",[string]$filetypes = "avi,wmv,mpg,asf,mp3,ogg,wav,wma,mp4,mkv,mov")

	#$filetypesarray = $filetypes.split(",") | where-object {$_ -ne ","}
	$filetypesmatch = "." + $filetypes.Replace(",", "|.")
	$playlisttype = $playlisttype.ToLower()
	$dir = get-childitem -literalPath $source -force
    $subdirs = @($Dir | where {$_.PSIsContainer -eq "True"} | Sort-Object $_.DirectoryName)
	Foreach ($subdir in $subdirs)
    {
		[int]$fileindex = 0
		$FileName = $subdir.Name + "." + $playlisttype
		$outfile = $destination + "\" + $FileName		

		$searchfiles = (Get-Childitem -literalPath $subdir.PSPath -recurse -force) | where { $_.Extension -match $filetypesmatch }
        Foreach ($searchfile in $searchfiles)
    	{
			if ($fileindex -eq 0)
			{
				switch ($playlisttype) {
					"mpcpl"
					{
						$output = "MPCPLAYLIST"
						Write-Output $output | Out-File $outfile -append
					}
					"pls"
					{
						$output = ""
						Write-Output $output | Out-File $outfile -append
					}
					default
					{
					}
				}
			}


			switch ($playlisttype) {
				"mpcpl"
				{
					[string]$output = [string]$fileindex + ",type,0"
					Write-Output $output | Out-File $outfile -append
					[string]$output = [string]$fileindex + ",filename," + $searchfile.FullName
					Write-Output $output | Out-File $outfile -append
					$fileindex = $fileindex + 1
				}
				"pls"
				{
					$fileindex = $fileindex + 1
					[string]$output = "File" + [string]$fileindex + "=" + $searchfile.FullName
					Write-Output $output | Out-File $outfile -append
				}
				default
				{
					[string]$output = $searchfile.FullName
					Write-Output $output | Out-File $outfile -append -Encoding ASCII
				}
			}
		}
		if ($searchfiles.Count -ge 1)
		{
			switch ($playlisttype) {
				"pls"
				{
					[string]$output = "NumberOfEntries=" + [string]$fileindex
					Write-Output $output | Out-File $outfile -append
				}
				default
				{
				}
			}
		}
	}

Active Directory LDAP Filter

Hi.

heute mal was technisches:

Ihr wolltet schon immer einmal von einem Benutzer alle Gruppen wissen inkl. der Vererbten Gruppen dieser Gruppen Also rekursive Gruppen?

Dann testet doch einmal ab einem Windows 2003 SP2 Active Directory folgenden LDAP-Filter:
(&(objectClass=group) (member:1.2.840.113556.1.4.1941:=<UserODN>))
<UserODN> = LDAP Pfad eines Objektes (z.B. Benutzer: CN=Administrator,CN=Users,DC=domain,DC=local)

Dadurch könnt Ihr euch einiges an Arbeit sparen, wenn es darum geht rekursive Gruppenmitgliedschaften auszulesen. Ihr könnt diesen Filter z.B. in eurem .Net Projekt verwenden und eine Liste ausgeben lassen.

Gruß,

Kellerman

Einen guten Rutsch

Hallo allesamt,

ich wünsche euch allen einen guten Rutsch ins neue Jahr.

Ich muss ja schon sagen ich kann es kaum noch abwarten, da in weniger als zwei Wochen es wieder mit Chuck, Leverage, Legend of the Seeker, Sanctuary, Numb3ers, Fringe, Bones, White Collar, The Vampire Diaries und The Mentalist weitergeht. Einen Monat müssen wir dummerweise noch auf Smallville warten.

Bis demnächst aus dem schönen kleinen Dürscheid,

Euer Matthias