CODICE
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <GUIEdit.au3>
#include <Skin.au3>
#include <array.au3>
SkinStartLibrary()
$RenamerForm = GUICreate("Renamer", 650, 460, 600, 300, -1, $WS_EX_ACCEPTFILES)
AddSkin($RenamerForm, "B-style.skf")
$link = ""
GUICtrlCreateLabel("Renamer", 285, 10, 108, 30)
GUICtrlSetFont(-1, 20, 400, 2, "Comic Sans MS", 1)
$Input_Path = GUICtrlCreateInput($link, 210, 60, 240, 20, $ES_AUTOHSCROLL)
$browse = GUICtrlCreateButton("Browse...", 465, 56)
$Edit_Name = GUICtrlCreateEdit("", 30, 120, 270, 250)
$Edit_NewName = GUICtrlCreateEdit("", 350, 120, 270, 250)
$action = GUICtrlCreateButton("Rename", 280, 410, 80, 30)
$clear_Name = GUICtrlCreateButton("Clear", 115, 378, 35, 15)
GUICtrlSetFont(-1, 8, 400, 2)
GUICtrlSetTip($clear_Name, "Pulisci il Testo", "Clear", 1, 1)
$clear_NewName = GUICtrlCreateButton("Clear", 383, 378, 37, 15)
GUICtrlSetFont(-1, 8, 400, 2)
GUICtrlSetTip($clear_NewName, "Pulisci il Testo", "Clear", 1, 1)
$number_Name = GUICtrlCreateButton("Number of File", 100, 96, 120, 20)
GUICtrlSetFont(-1, 8, 400, 2)
GUICtrlSetTip($clear_NewName, "Ottieni il numero dei file", "Clear", 1, 1)
$number_NewName = GUICtrlCreateButton("Number of File", 427, 96, 120, 20)
GUICtrlSetFont(-1, 8, 400, 2)
GUICtrlSetTip($clear_NewName, "Ottieni il numero dei file", "Clear", 1, 1)
$extract = GUICtrlCreateButton("Extract", 155, 378, 45, 15)
GUICtrlSetFont(-1, 8, 400, 2)
GUICtrlSetTip($extract, "Estrai i nomi in un file di testo", "Extract", 1, 1)
$insert = GUICtrlCreateButton("Insert", 425, 378, 38, 15)
GUICtrlSetFont(-1, 8, 400, 2)
GUICtrlSetTip($insert, "Inserisci i nomi da un file di testo", "Insert", 1, 1)
$replace = GUICtrlCreateButton("Replace", 468, 378, 45, 15)
GUICtrlSetFont(-1, 8, 400, 2)
GUICtrlSetTip($replace, "Sostituisci parole con altre", "Replace", 1, 1)
$randomize = GUICtrlCreateButton("Random", 518, 378, 45, 15)
GUICtrlSetFont(-1, 8, 400, 2)
GUICtrlSetTip($randomize, "Genera una parola casuale", "Random", 1, 1)
GUISetState(@SW_SHOW)
GUICtrlSetState($Edit_Name, $GUI_DROPACCEPTED)
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
Exit
Case $browse
$path = FileSelectFolder("Scegli la cartella che contiene i file da rinominare!", @HomePath, 4, "", $RenamerForm)
If StringRight($path, 1) <> "\" Then
$path = $path & "\"
EndIf
$files = _FileListToArray($path, "*", 1)
If @error == 4 Then
MsgBox(0, "Errore!", "Non ho trovato nessun file!")
Else
For $i = 1 To $files[0]
If StringRight(GUICtrlRead($Edit_Name), 1) <> "" Then
_GUICtrlEdit_AppendText($Edit_Name, @CRLF & $path & $files[$i])
ElseIf StringRight(GUICtrlRead($Edit_Name), 1) == "" Then
_GUICtrlEdit_AppendText($Edit_Name, $path & $files[$i])
EndIf
Next
EndIf
Case $action
$read_Name = GUICtrlRead($Edit_Name)
$tmp_Name = StringReplace($read_Name, @CRLF, "?")
$Name = StringSplit($tmp_Name, "?")
$read_NewName = GUICtrlRead($Edit_NewName)
$tmp_NewName = StringReplace($read_NewName, @CRLF, "?")
$NewName = StringSplit($tmp_NewName, "?")
If $Name[0] > $NewName[0] Then
MsgBox(00, "Errore!", "Pareggia il numero delle righe in entrambi i box")
EndIf
If $Name[0] < $NewName[0] Then
MsgBox(00, "Errore!", "Pareggia il numero delle righe in entrambi i box")
EndIf
If $Name[0] == $NewName[0] Then
For $i = 1 To $Name[0]
If StringInStr($NewName[$i], "\") <> 0 Or StringInStr($NewName[$i], "/") <> 0 Or StringInStr($NewName[$i], ":") <> 0 Or StringInStr($NewName[$i], "*") <> 0 Or StringInStr($NewName[$i], "?") <> 0 Or StringInStr($NewName[$i], "<") <> 0 Or StringInStr($NewName[$i], ">") <> 0 Or StringInStr($NewName[$i], "|") <> 0 Then
MsgBox(00, "Errore!", "I caratteri: \ / * ? : < > | Non possono essere inseriti")
ExitLoop
Else
For $i = 1 To $Name[0]
$tmp_ext = StringSplit($Name[$i], ".")
$ext = "." & $tmp_ext[$tmp_ext[0]]
$tmp_link = StringSplit($Name[$i], "\")
$link = _ArrayToString($tmp_link, "\", 1, $tmp_link[0] - 1) & "\"
If $NewName[$i] == "" Then
$renaming = FileMove($Name[$i], $Name[$i])
ElseIf $NewName[$i] <> "" Then
$renaming = FileMove($Name[$i], $link & $NewName[$i] & $ext)
EndIf
Next
If $renaming <> 0 Then
MsgBox(00, "Rinominazione completata!", "I File sono stati rinominati")
GUICtrlSetData($Edit_Name, "")
GUICtrlSetData($Edit_NewName, "")
Run(@ComSpec & ' /c ' & 'explorer.exe ' & $link & '', "", @SW_HIDE)
Else
MsgBox(00, "Rinominazione Fallita!", "Non sono riuscito a rinominare i file")
EndIf
EndIf
Next
EndIf
Case $clear_Name
GUICtrlSetData($Edit_Name, "")
Case $clear_NewName
GUICtrlSetData($Edit_NewName, "")
Case $extract
$txt = FileOpen(@DesktopDir & "\extract.txt", 1)
$read_NewName = GUICtrlRead($Edit_Name)
$tmp_NewName = StringReplace($read_NewName, @CRLF, "?")
$split = StringSplit($tmp_NewName, "?")
For $i = 1 To $split[0]
$tmp_NameFile = StringSplit($split[$i], "\")
$NameFile = StringTrimRight($tmp_NameFile[$tmp_NameFile[0]], 4)
FileWrite($txt, $NameFile & @CRLF)
Next
FileClose($txt)
Run(@ComSpec & ' /c ' & 'notepad.exe "' & @DesktopDir & '\extract.txt"', "", @SW_HIDE)
Case $insert
$TXTPath = FileOpenDialog("Scegli il File di testo", @HomePath, "Text files (*.txt)", 1, "", $RenamerForm)
If $TXTPath == "" Then
MsgBox(00, "Errore!", "Scegli un file txt")
ElseIf $TXTPath <> "" Then
$read_txt = FileRead($TXTPath)
If StringRight(GUICtrlRead($Edit_NewName), 1) <> "" Then
_GUICtrlEdit_AppendText($Edit_NewName, @CRLF & $read_txt)
ElseIf StringRight(GUICtrlRead($Edit_NewName), 1) == "" Then
_GUICtrlEdit_AppendText($Edit_NewName, $read_txt)
EndIf
EndIf
Case $replace
$Replace_gui = GUICreate("Replace", 290, 200, 38, 15)
GUICtrlCreateLabel("Rinomina:", 65, 35, 100, 20)
GUICtrlSetFont(-1, 11, 400, 2, "Comic Sans MS", 1)
$old = GUICtrlCreateInput("", 30, 60, 130, 19)
GUICtrlCreateLabel("In:", 80, 95, 100, 20)
GUICtrlSetFont(-1, 11, 400, 2, "Comic Sans MS", 1)
$new = GUICtrlCreateInput("", 30, 115, 130, 19)
$action_replace = GUICtrlCreateButton("Replace", 200, 82, 70, 30)
GUICtrlSetFont(-1, 11, 400, 2, "Comic Sans MS", 1)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $action_replace
$replaced = StringReplace(GUICtrlRead($Edit_NewName), GUICtrlRead($old), GUICtrlRead($new))
GUICtrlSetData($Edit_NewName, $replaced)
EndSwitch
WEnd
GUIDelete($Replace_gui)
Case $number_Name
$read_Name = GUICtrlRead($Edit_Name)
$tmp_Name = StringReplace($read_Name, @CRLF, "?")
$Name = StringSplit($tmp_Name, "?")
MsgBox(00, "Ci sono...", $Name[0]&" File/s")
Case $number_NewName
$read_NewName = GUICtrlRead($Edit_NewName)
$tmp_NewName = StringReplace($read_NewName, @CRLF, "?")
$NewName = StringSplit($tmp_NewName, "?")
MsgBox(00, "Ci sono...", $NewName[0]&" File/s")
Case $randomize
$Random_gui = GUICreate("Random Words", 290, 200, 38, 15)
GUICtrlCreateLabel("Quanti ne creo?", 80, 25, 130, 20)
GUICtrlSetFont(-1, 10, 400, 2)
$rows = GUICtrlCreateInput("", 80, 50, 130, 19)
GUICtrlCreateLabel("Di quanti caratteri?", 80, 85, 160, 20)
GUICtrlSetFont(-1, 10, 400, 2)
$char = GUICtrlCreateInput("", 80, 110, 130, 19)
$submit = GUICtrlCreateButton("Genera", 100, 150, 80, 25)
GUICtrlSetFont(-1, 10, 400)
GUISetState(@SW_SHOW)
While 1
$msg = GUIGetMsg()
Switch $msg
Case $GUI_EVENT_CLOSE
ExitLoop
Case $submit
Local $all_num[GUICtrlRead($char)+1]
Local $array[20] = ["", "l", "d", "g", "s", "j", "o", "q", "m", "a", "h", "à", "è", "ù", "w", "x", "z", "$", "%", "^"]
For $x = 1 to GUICtrlRead($rows)
For $i = 1 to GUICtrlRead($char)
$num = Random(1, 19)
$all_num[$i] = $num
_GUICtrlEdit_AppendText($Edit_NewName, $array[$all_num[$i]])
Next
_GUICtrlEdit_AppendText($Edit_NewName, @CRLF)
Next
EndSwitch
WEnd
GUIDelete($Random_gui)
EndSwitch
WEnd