Hier die Lösung:
Code
include winim/[inc\shellapi]
import os
# The directory specified as a parameter is searched for MP3 files.
# Example: "f:\Audio\MP3\Top\Top 40 Oldies Forever" - without backslash at the end of the path!
var sPath:string
echo "\nparamCount() = " & $paramCount()
if paramCount() > 0:
for p in 1..paramCount():
sPath = paramStr(p)
echo "sPath = " & sPath
# With a backslash at the end, the string delimiter that follows is masked
# so that it remains at the end of the parameter instead of the backslash.
# "c:\temp\" ==>> c:\temp"
echo "sPath[^1..^1] = " & sPath[^1..^1]
echo "sPath[^1..^1] == $chr(34) = " & $(sPath[^1..^1] == $chr(34))
#if sPath[sPath.len-1..sPath.len-1] == $chr(34):
if sPath[^1..^1] == $chr(34):
echo "Bad path! Trim trailing quote"
sPath = sPath[0..^2] # sPath[0..sPath.len-2]
echo "sPath = " & sPath
var fileSplit = splitFile(sPath)
echo "dir = " & fileSplit.dir
echo "name = " & fileSplit.name
echo "ext = " & fileSplit.ext
if PathIsDirectoryA(sPath) == FILE_ATTRIBUTE_DIRECTORY:
echo "PathIsDirectoryA(sPath): sPath is a directory!"
# It works that way too, but is more cumbersome.
#[ try:
var oFileInfo = getFileInfo(sPath)
if $oFileInfo.kind == "pcDir":
echo "getFileInfo(sPath): sPath is a directory!"
except:
echo "getFileInfo(sPath) failed!"
]#
# Iterate over all the files that match the pattern.
for path in walkFiles($sPath & "\\*.mp3"):
echo(path)
# Iterate over all the directories that match the pattern.
#for kind, path in walkDir(sPath):
# Iterate over all the files and directories that match the pattern.
#for path in walkPattern($sPath & "\\*.mp3"): #
Alles anzeigen