Hallo
mit folgendem Beispielcode ist es möglich, bis zu sechs verschiedene Zeichenersetzungen, in Datei- und Verzeichnisnamen recursiv vorzunehmen.
Versuche ich beispielsweise 10 verschiedene Zeichenersetzungen, bekomme ich einen Fehler:
Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
If BitAND($aFilesFolder[$i][7], $FILE_ATTRIBUTE_DIRECTORY) Then _RenameRecursive($sPath & $aFilesFolder[$i][0])
If BitAND(^ ERROR
Warum das ganze:
Es dürfen nur Buchstaben, Zahlen, Binde- und Unterstrich in meinenDatei- und Verzeichnisnamen zugelassen werden. Alle anderen Zeichen müssen aus bestimmten Gründen aus den Verzeichnis und Dateinamen entfernt werden.
#include <APIFilesConstants.au3>
#include <APIShellExConstants.au3>
#include <GDIPlus.au3>
#include <GDIPlusConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WinAPIConstants.au3>
#include <WinAPIFiles.au3>
#include <WinAPIShellEx.au3>
#include <WindowsConstants.au3>
Global $sPath = FileSelectFolder(' Bitte Verzeichnis auswählen !', '')
If Not FileExists($sPath) Then Exit
;===================================================================
;Codebeginn für die Animation UEZ
;===================================================================
_GDIPlus_Startup()
Global $iW = 400, $iH = 250
Global Const $hGUI = GUICreate("Loading Spinner", $iW, $iH, -1, -1, $WS_POPUP); $WS_EX_TOPMOST)
Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState()
Global $hHBmp_BG, $hB, $iPerc = 0, $iSleep = 30, $s = 0, $t, $m = 0
GUIRegisterMsg($WM_TIMER, "PlayAnim")
DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0)
;===================================================================
;Code-Beginn für das umbenennen der Verzeichnisse und Dateien
;===================================================================
_RenameRecursive($sPath)
Func _RenameRecursive($sPath)
If StringRight($sPath, 1) <> '\' Then $sPath &= '\'
Local $aFilesFolder = _WinAPI_EnumFiles($sPath,0)
If @error Then Return
For $i = 1 To $aFilesFolder[0][0]
If BitAND($aFilesFolder[$i][4], $FILE_ATTRIBUTE_DIRECTORY) Then _RenameRecursive($sPath & $aFilesFolder[$i][0])
_WinAPI_ShellFileOperation($sPath & $aFilesFolder[$i][0], $sPath & StringReplace(StringReplace(StringReplace(StringReplace(StringReplace($aFilesFolder[$i][0], "ä","ae"), "ö","oe"), "ü","ue"), " ","_"), "ß","ss"), $FO_RENAME, $FOF_SILENT)
Next
EndFunc
GUIRegisterMsg($WM_TIMER, "")
_WinAPI_DeleteObject($hHBmp_BG)
_GDIPlus_Shutdown()
GUIDelete()
Sleep(200)
MsgBox(64,"", "Die Verzeichnisse und Dateien wurden umbenannt!")
Exit
;===================================================================
;Code für die Animation von UEZ
;===================================================================
Func PlayAnim()
$hHBmp_BG = _GDIPlus_MultiColorLoader($iW, $iH, "Die Verzeichnisse und Dateien werden umbenannt. Bitte warten! ")
$hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG)
If $hB Then _WinAPI_DeleteObject($hB)
_WinAPI_DeleteObject($hHBmp_BG)
EndFunc ;==>PlayAnim
Func _GDIPlus_MultiColorLoader($iW, $iH, $sText = "", $sFont = "Verdana", $bHBitmap = True)
Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($hGfx, 4 + (@OSBuild > 5999))
_GDIPlus_GraphicsSetTextRenderingHint($hGfx, 3)
_GDIPlus_GraphicsSetPixelOffsetMode($hGfx, $GDIP_PIXELOFFSETMODE_HIGHQUALITY)
_GDIPlus_GraphicsClear($hGfx, 0xFF232323)
Local $iRadius = ($iW > $iH) ? $iH * 0.6 : $iW * 0.6
Local Const $hPath = _GDIPlus_PathCreate()
_GDIPlus_PathAddEllipse($hPath, ($iW - ($iRadius + 24)) / 2, ($iH - ($iRadius + 24)) / 2, $iRadius + 24, $iRadius + 24)
Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
_GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFFFFFFF)
_GDIPlus_PathBrushSetSurroundColor($hBrush, 0x08101010)
_GDIPlus_PathBrushSetGammaCorrection($hBrush, True)
Local $aBlend[4][2] = [[3]]
$aBlend[1][0] = 0 ;0% center color
$aBlend[1][1] = 0 ;position = boundary
$aBlend[2][0] = 0.33 ;70% center color
$aBlend[2][1] = 0.1 ;10% of distance boundary->center point
$aBlend[3][0] = 1 ;100% center color
$aBlend[3][1] = 1 ;center point
_GDIPlus_PathBrushSetBlend($hBrush, $aBlend)
Local $aRect = _GDIPlus_PathBrushGetRect($hBrush)
_GDIPlus_GraphicsFillRect($hGfx, $aRect[0], $aRect[1], $aRect[2], $aRect[3], $hBrush)
_GDIPlus_PathDispose($hPath)
_GDIPlus_BrushDispose($hBrush)
Local Const $hBrush_Black = _GDIPlus_BrushCreateSolid(0xFF161616)
_GDIPlus_GraphicsFillEllipse($hGfx, ($iW - ($iRadius + 10)) / 2, ($iH - ($iRadius + 10)) / 2, $iRadius + 10, $iRadius + 10, $hBrush_Black)
Local Const $hBitmap_Gradient = _GDIPlus_BitmapCreateFromScan0($iRadius, $iRadius)
Local Const $hGfx_Gradient = _GDIPlus_ImageGetGraphicsContext($hBitmap_Gradient)
_GDIPlus_GraphicsSetSmoothingMode($hGfx_Gradient, 4 + (@OSBuild > 5999))
Local Const $hMatrix = _GDIPlus_MatrixCreate()
Local Static $r = 0
_GDIPlus_MatrixTranslate($hMatrix, $iRadius / 2, $iRadius / 2)
_GDIPlus_MatrixRotate($hMatrix, $r)
_GDIPlus_MatrixTranslate($hMatrix, -$iRadius / 2, -$iRadius / 2)
_GDIPlus_GraphicsSetTransform($hGfx_Gradient, $hMatrix)
$r += 10
Local Const $hBrush_Gradient = _GDIPlus_LineBrushCreate($iRadius, $iRadius / 2, $iRadius, $iRadius, 0xFF000000, 0xFF33CAFD, 1)
_GDIPlus_LineBrushSetGammaCorrection($hBrush_Gradient)
_GDIPlus_GraphicsFillEllipse($hGfx_Gradient, 0, 0, $iRadius, $iRadius, $hBrush_Gradient)
_GDIPlus_GraphicsFillEllipse($hGfx_Gradient, 4, 4, $iRadius - 8, $iRadius - 8, $hBrush_Black)
_GDIPlus_GraphicsDrawImageRect($hGfx, $hBitmap_Gradient, ($iW - $iRadius) / 2, ($iH - $iRadius) / 2, $iRadius, $iRadius)
_GDIPlus_BrushDispose($hBrush_Gradient)
_GDIPlus_BrushDispose($hBrush_Black)
_GDIPlus_GraphicsDispose($hGfx_Gradient)
_GDIPlus_BitmapDispose($hBitmap_Gradient)
_GDIPlus_MatrixDispose($hMatrix)
Local Const $hFormat = _GDIPlus_StringFormatCreate()
Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFont)
Local Const $hFont = _GDIPlus_FontCreate($hFamily, $iRadius / 10)
_GDIPlus_StringFormatSetAlign($hFormat, 1)
_GDIPlus_StringFormatSetLineAlign($hFormat, 1)
Local $tLayout = _GDIPlus_RectFCreate(0, 0, $iW, $iH)
Local Static $iColor = 0x00, $iDir = 13
Local $hBrush_txt = _GDIPlus_BrushCreateSolid(0xFF000000 + 0x010000 * $iColor + 0x0100 * $iColor + $iColor)
_GDIPlus_GraphicsDrawStringEx($hGfx, $sText, $hFont, $tLayout, $hFormat, $hBrush_txt)
$iColor += $iDir
If $iColor > 0xFF Then
$iColor = 0xFF
$iDir *= -1
ElseIf $iColor < 0x16 Then
$iDir *= -1
$iColor = 0x16
EndIf
_GDIPlus_BrushDispose($hBrush_txt)
_GDIPlus_FontDispose($hFont)
_GDIPlus_FontFamilyDispose($hFamily)
_GDIPlus_StringFormatDispose($hFormat)
_GDIPlus_GraphicsDispose($hGfx)
If $bHBitmap Then
Local $hHBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
_GDIPlus_BitmapDispose($hBitmap)
Return $hHBITMAP
EndIf
Return $hBitmap
EndFunc
Alles anzeigen
Jetzt sollte ich aber bis zu (geschätzten) 30 Varianten für verschiedene Zeichenersetzungen, in Datei- und Verzeichnisnamen recursiv vorzunehmen können.
Würdet Ihr mir bitte das eine oder andere Beispiel nennen, wie Ihr das Vorhaben am sinnvollsten umsetzen würdet?