E Uala, Renamer si aggiunge alla lista

« Older   Newer »
  Share  
Marduk
CAT_IMG Posted on 25/4/2011, 23:50     +1   -1




Era un pò di tempo che volevo postarlo, ma ho passato questi ultimi giorni a ridargli un occhiatina ed aggiungerci qualche funzione carina. Renamer, dal nome è quasi ovvio, è un rinominatore di massa con svariate funzioni carine.

Qui il download ;) http://nativity.altervista.org/#gallery

Source:
SPOILER (click to view)
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


Edited by Marduk - 26/4/2011, 09:54
 
Top
xMasteRx
CAT_IMG Posted on 26/4/2011, 04:06     +1   -1




bravo, ci sono un po di bug [come per esempio quando fai browse e anulla] però è apposto ^^ comunque potresti fare una seconda versione più completa lol, come per esempio sostituire i pulsanti number of file con una label e il numero...
comunque sia metti il source in qualche posto... l'ho provato l'eseguibile perché penso possa fidarmi di te, però non è sempre così con tutte le persone...
 
Top
Doch88
CAT_IMG Posted on 26/4/2011, 08:31     +1   -1




Da quanto mi ricordo si scriveva "Et voilá" asd
 
Top
Marduk
CAT_IMG Posted on 26/4/2011, 08:53     +1   -1




CITAZIONE (Doch88 @ 26/4/2011, 09:31) 
Da quanto mi ricordo si scriveva "Et voilá" asd

XD l'ho fatto di proposito... cmq scusami Master, l'ho metto sul primo post...

PS=non avevo pensato ad una label... vedrò che posso fare... per i bug potreste darmi una mano a trovarli?? Sto fixando quello del pulsante browse...

Grazie mille ^_^
 
Top
*Sym98*
CAT_IMG Posted on 26/4/2011, 10:27     +1   -1




Bravo, bel programma :D
 
Top
bradipooso
CAT_IMG Posted on 26/4/2011, 19:38     +1   -1





:shifty:

 
Top
Marduk
CAT_IMG Posted on 26/4/2011, 20:11     +1   -1




CITAZIONE (bradipooso @ 26/4/2011, 20:38) 

:shifty:

ahahahahahahaha<hahahahahahahahahaahahahahahahashahaahahahahah
 
Top
xMasteRx
CAT_IMG Posted on 26/4/2011, 20:49     +1   -1




xD
a mente ora mi viene poi il bug che se clicchi il pulsante normalmente ritorna un elemento in più [0 elementi nella lista dice 1], magari perché usi una array e non usi il elemento 0
 
Top
Marduk
CAT_IMG Posted on 26/4/2011, 21:28     +1   -1




no, in realtà, quel bottone è stato creato per capire cosa si deve fare quando incorre l'errore di pareggiare le righe... quindi indica le righe e non i files... ero indeciso su cosa scrivere nella msgbox... cmq questo è il mio rapporto:

CODICE
26/04/2011 10:13 = BugFix su FileSelectFolder()
26/04/2011 10:13 = BugFix su tooltips scambiate
26/04/2011 10:33 = BugFix su scelta di path invalide
26/04/2011 12:05 = BugFix su FileOpenDialog
26/04/2011 12:05 = BugFix caratteri speciali
26/04/2011 00:35 = Esclusione file nascosti da GuiEdit
26/04/2011 UNDETERMINATE = Possibilità di inserire wildcards
26/04/2011 UNDETERMINATE = Possibilità di inserire veri e propri comandi con caratteri inusabili per la rinominazione = |
26/04/2011 UNDETERMINATE = highlight delle parole ricercate in replace
26/04/2011 1:29 = Numero righe direttamente in label


Edited by Marduk - 27/4/2011, 01:36
 
Top
8 replies since 25/4/2011, 23:50   186 views
  Share