#AutoIt3Wrapper_Res_Fileversion=1.1.36 global $my_version = "1.1.36" #cs MangleeZee - A truly dangerous renaming utility for Windows. From corz.org #ce global $my_url = "https://corz.org/windows/software/mangleezee/" #include #include #include #include #include #include #include #include #include #include #include "Includes\corzShared.au3" #include "Includes\corzRegistry.au3" global $my_name = "MangleeZee" global $ini_file = $my_name & ".ini" global const $__EDITCONSTANT_WS_VSCROLL = 2097152 global const $__EDITCONSTANT_WS_HSCROLL = 1048576 global const $GROUP_BOTTOM_MARGIN = 6 AutoItSetOption("GUIOnEventMode", 1) AutoItSetOption("GUICoordMode", 0) AutoItSetOption("TrayMenuMode", 11) AutoItSetOption("TrayOnEventMode", 1) TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, "TrayToggleWindow") HotKeySet("{Esc}", "HKDoQuit") global $tmp_dir = @TempDir & "\MangleeZeeTempo" global $data_parent = @AppDataDir & "\corz\" & $my_name global $switches, $exit, $disk, $path, $mzGUI, $installed_ini global $log_file = false, $log_append global $x, $y, $width, $height, $min_width, $width_magic, $min_height, $height_magic, $max_height global $def_ix, $def_iy, $def_iw, $input_x, $input_y, $input_width global $show_tips, $beep, $taskbar_entry, $explorer_context global $timer_stamp = 0, $visible, $hover_to_show, $hover_sensitivity global $tray_explorer_context, $always_on_top, $tray_always_on_top, $tray_undo global $tray_prefs, $tray_editini, $tray_viewlog, $tray_quit global $hot_quit_key, $hot_quit_label, $hot_undo_key, $hot_undo_label, $hot_prefs_key, $hot_prefs_label, $hot_ini_key, $hot_ini_label, $hot_log_key, $hot_log_label global $def_source_folder, $def_file_mask, $def_search_for, $def_replace_with, $def_extension global $undos, $max, $info_time global $recursive, $source_folder, $do_folders, $only_folders, $file_mask, $extension, $search_for, $replace_with, $use_regexp, $rep_limit, $match_name global $but_undo, $chk_recursive, $chk_do_folders, $chk_only_folders, $chk_use_regexp, $chk_match_name global $combo_source_folder, $combo_file_mask, $combo_extension, $combo_search_for, $combo_replace_with, $inp_rep_limit global $add_search, $add_replace global $count, $count_end, $count_ints global $fade_in, $fade_speed, $rename_hidden, $rename_checksum_entries, $checksum_extension, $ignore_files, $not_replaced global $reg_user, $reg_to, $waited = false, $wait_for = 0, $display_user global $garbage_collector, $reg_url, $versioncheck_url, $download_url, $gui_about global $quit = -99 func RecurseDirMZ($dir, $mask, $dont_recurse=false, $dump="", $return_dirs=false, $mx=1000000, $dirs_match_mask=false, $convert_names=false, $convert_level=2) local $n_dirnames[$mx] local $n_dircount = 0 local $n_file local $n_search local $file_array local $filenames local $matching_dirs ; local $filecount local $dircount = 1 if StringRight($dir, 1) = "\" then $dir = StringTrimRight($dir, 1) $n_dirnames[$dircount] = $dir if not FileExists($dir) then return 0 while $dircount > $n_dircount if $quit = 1 then return $n_dircount += 1 $n_search = FileFindFirstFile($n_dirnames[$n_dircount] & "\*.*") while 1 $n_file = FileFindnextFile($n_search) if @Error then FileClose($n_file) exitloop endif if $n_file = "." or $n_file = ".." then continueloop if $convert_names = $ON then local $cn_file = BaseName(ConvertNames($n_dirnames[$n_dircount] & "\" & $n_file, $convert_level)) if $n_file <> $cn_file then $n_file = $cn_file endif $n_file = $n_dirnames[$n_dircount] & "\" & $n_file if StringInStr(FileGetAttrib($n_file), "D") and not $dont_recurse then $dircount += 1 $n_dirnames[$dircount] = $n_file endif wend FileClose($n_search) if StringInStr($mask, ",", 2) then local $mask_array = StringSplit($mask, ",") else local $mask_array[2] = [1, $mask] endif for $mask_c = 1 to $mask_array[0] $n_search = FileFindFirstFile($n_dirnames[$n_dircount] & "\" & $mask_array[$mask_c]) if $n_search = -1 then continueloop if @Error then FileClose($n_search) exitloop endif while 1 $n_file = FileFindnextFile($n_search) if @Error then FileClose($n_file) exitloop endif if $n_file = "." or $n_file = ".." then continueloop if $convert_names = $ON then $cn_file = BaseName(ConvertNames($n_dirnames[$n_dircount] & "\" & $n_file, $convert_level)) if $n_file <> $cn_file then $n_file = $cn_file endif $n_file = $n_dirnames[$n_dircount] & "\" & $n_file if not StringInStr(FileGetAttrib($n_file), "D") then ; $filecount += 1 $filenames &= $n_file & $MSG_LF else $matching_dirs &= $n_file & "|" endif wend FileClose($n_search) next FileClose($n_search) wend if $return_dirs then local $tmp_str = "" local $i = 1 if $dirs_match_mask then $matching_dirs = StringTrimRight($matching_dirs, 1) $n_dirnames = StringSplit($matching_dirs, "|") return $n_dirnames else while $n_dirnames[$i] <> "" $tmp_str &= $n_dirnames[$i] & "|" $i += 1 wend $tmp_str = StringTrimRight($tmp_str, 1) $n_dirnames = StringSplit($tmp_str, "|") return $n_dirnames endif endif $filenames = StringTrimRight($filenames, 1) if $filenames = "" then return 0 $file_array = StringSplit($filenames, $MSG_LF) if $dump then local $dump_file = FileOpen($dump, 2) FileWrite($dump_file, $filenames) FileClose($dump_file) endif return ($file_array) endfunc func ConvertNames($some_path, $convert_level=2) local $ab_file = $some_path local $ub_file = StringToBinary($some_path, $convert_level) $ab_file = BinaryToString($ub_file, 1) if $some_path <> $ab_file then $some_path = FileGetShortName($some_path) endif return $some_path endfunc global $me_app, $portable; if @Compiled then $me_app = @ScriptFullPath else $me_app = "" & $my_name & ".exe" endif if $cmdline[0] then if $cmdline[0] > 1 then $switches = StringStripWS($cmdline[1], 3) endif $path = StringStripWS($cmdline[$cmdline[0]], 3) endif if $path = "portable" then $installed_ini = FileInstall("Resources\MangleeZee.ini", @ScriptDir & "\" & $ini_file) $path = "" endif if FileExists(@ScriptDir & "\" & $ini_file) then $portable = true $ini_path = @ScriptDir & "\" & $ini_file else if not FileExists($data_parent) then DirCreate($data_parent) $ini_path = $data_parent & "\" & $ini_file $installed_ini = FileInstall("Resources\MangleeZee.ini", $ini_path) if $installed_ini then IniWrite($ini_path, $my_name, "version", $my_version) endif endif if not $installed_ini then UpdateMZINIFile() GetPrefs() func UpdateMZINIFile() local $old_version = IniRead($ini_path, $my_name, "version", 0) if $my_version <= $old_version then return local $tmp_ini = @TempDir & "\" & $ini_file & ".new" FileInstall("Resources\MangleeZee.ini", $tmp_ini, 1) local $existing_sections = IniReadSectionNames($tmp_ini) for $a = 1 to $existing_sections[0] if $existing_sections[$a] <> $my_name then IniDelete($tmp_ini, $existing_sections[$a]) endif next $existing_sections = IniReadSectionNames($ini_path) for $a = 1 to $existing_sections[0] local $section = IniReadSection($ini_path, $existing_sections[$a]) if IsArray($section) then for $b = 1 to $section[0][0] if StringLeft($section[$b][0], 1) <> "#" then IniWrite($tmp_ini, $existing_sections[$a], $section[$b][0], $section[$b][1]) endif next endif next FileMove($ini_path, GetParent($ini_path) & "\[" & @Year & "-" & @Mon & "-" & @MDay & "@" & @Hour & "." & @Min & "] " & $ini_file) FileMove($tmp_ini, $ini_path, 1) IniWrite($ini_path, $my_name, "version", $my_version) endfunc if $path then $source_folder = $path IniWrite($ini_path, $my_name, "source_folder", $source_folder) endif MakeTray() MakeGUI() SetAlwaysOnTop() SetHotKeys() TraySetOnEvent($TRAY_EVENT_MOUSEOVER, "WindowToFront") while $quit = -99 Sleep(50) wend func MakeGUI() if $taskbar_entry = $ON then $mzGUI = GUICreate($my_name, $width, $height, $x, $y, Bitor($WS_CAPTION, $WS_SYSMENU, $WS_MINIMIZEBOX, $WS_SIZEBOX), $WS_EX_ACCEPTFILES) else local $dummy_container = GUICreate("", -1, -1, 0, 0, 0, Bitor($WS_EX_ACCEPTFILES, $WS_EX_TOOLWINDOW)) $mzGUI = GUICreate($my_name, $width, $height, $x, $y, Bitor($WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_MINIMIZEBOX, $WS_SIZEBOX), -1, $dummy_container) endif GUISetIcon($me_app, 0, $mzGUI) GUISetOnEvent($GUI_EVENT_CLOSE, "MenuDoQuit") GUISetOnEvent($GUI_EVENT_RESIZED, "CheckSize") GUISetOnEvent($GUI_EVENT_DROPPED, "GetDroppedItem") GUISetOnEvent($GUI_EVENT_RESIZED, "ResizeCheckSize") GUISetOnEvent($GUI_EVENT_PRIMARYUP, "PrimaryUpCheckSize") GUISetOnEvent($GUI_EVENT_MINIMIZE, "TrayToggleWindow") GUISetCoord(5, 5) local $group_source = GUICtrlCreateGroup("Source.. ", 0, 0, $width - 10, 70) local $lab_source_folder = GUICtrlCreateLabel("Folder:", 8, 20, 50) $combo_source_folder = GUICtrlCreateCombo("", 55, -2, $width - 90, 200) GUICtrlSetState(-1, $GUI_DROPACCEPTED) BuildCombo($combo_source_folder, "source_folder") local $ctxt_source = GUICtrlCreateContextMenu($combo_source_folder) GUICtrlCreateMenuItem("Delete this item", $ctxt_source) GUICtrlSetOnEvent(-1, "WipeSourceFolderItem") GUICtrlCreateMenuItem("Wipe this list", $ctxt_source) GUICtrlSetOnEvent(-1, "WipeSourceFolderList") GUICtrlCreateMenuItem("", $ctxt_source) GUICtrlCreateMenuItem("Load default group", $ctxt_source) GUICtrlSetOnEvent(-1, "LoadDefSourceFolderGrp") GUICtrlCreateMenuItem("Set as default group", $ctxt_source) GUICtrlSetOnEvent(-1, "SetDefSourceFolderGrp") GUICtrlCreateMenuItem("", $ctxt_source) GUICtrlCreateMenuItem("Sort this list", $ctxt_source) GUICtrlSetOnEvent(-1, "SortSourceFolderList") GUISetCoord(13, 50) local $lab_file_mask = GUICtrlCreateLabel("File Mask:", 0, 0, 50) $combo_file_mask = GUICtrlCreateCombo("", 55, -2, $width - 90, 200) BuildCombo($combo_file_mask, "file_mask") local $ctxt_file_mask = GUICtrlCreateContextMenu($combo_file_mask) GUICtrlCreateMenuItem("Delete this item", $ctxt_file_mask) GUICtrlSetOnEvent(-1, "WipeFileMaskItem") GUICtrlCreateMenuItem("Wipe this list", $ctxt_file_mask) GUICtrlSetOnEvent(-1, "WipeFileMaskList") GUICtrlCreateMenuItem("", $ctxt_file_mask) GUICtrlCreateMenuItem("Load default group", $ctxt_file_mask) GUICtrlSetOnEvent(-1, "LoadDefFileMaskGrp") GUICtrlCreateMenuItem("Set as default group", $ctxt_file_mask) GUICtrlSetOnEvent(-1, "SetDefFileMaskGrp") GUICtrlCreateMenuItem("", $ctxt_file_mask) GUICtrlCreateMenuItem("Sort this list", $ctxt_file_mask) GUICtrlSetOnEvent(-1, "SortFileMaskList") GUISetCoord(5, 78) local $group_name = GUICtrlCreateGroup("Name.. ", 0, 0, $width - 10, 70) local $lab_search_for = GUICtrlCreateLabel("Search for:", 8, 20, 55) GUICtrlSetOnEvent(-1, "InputSearchString") $combo_search_for = GUICtrlCreateCombo("", 55, -2, 100, 200) BuildCombo($combo_search_for, "search_for") local $ctxt_search_for = GUICtrlCreateContextMenu($combo_search_for) GUICtrlCreateMenuItem("Delete this item", $ctxt_search_for) GUICtrlSetOnEvent(-1, "WipeSearchForItem") GUICtrlCreateMenuItem("Wipe this list", $ctxt_search_for) GUICtrlSetOnEvent(-1, "WipeSearchForList") GUICtrlCreateMenuItem("", $ctxt_search_for) GUICtrlCreateMenuItem("Load default group", $ctxt_search_for) GUICtrlSetOnEvent(-1, "LoadDefSearchForGrp") GUICtrlCreateMenuItem("Set as default group", $ctxt_search_for) GUICtrlSetOnEvent(-1, "SetDefSearchForGrp") GUICtrlCreateMenuItem("", $ctxt_search_for) GUICtrlCreateMenuItem("Sort this list", $ctxt_search_for) GUICtrlSetOnEvent(-1, "SortSearchForList") local $lab_replace_with = GUICtrlCreateLabel("Replace with:", 105, 2, 65) GUICtrlSetOnEvent(-1, "InputReplaceString") $combo_replace_with = GUICtrlCreateCombo("", 70, -2, 100, 200) BuildCombo($combo_replace_with, "replace_with") local $ctxt_replace_with = GUICtrlCreateContextMenu($combo_replace_with) GUICtrlCreateMenuItem("Delete this item", $ctxt_replace_with) GUICtrlSetOnEvent(-1, "WipeReplaceItem") GUICtrlCreateMenuItem("Wipe this list", $ctxt_replace_with) GUICtrlSetOnEvent(-1, "WipeReplaceList") GUICtrlCreateMenuItem("", $ctxt_replace_with) GUICtrlCreateMenuItem("Load default group", $ctxt_replace_with) GUICtrlSetOnEvent(-1, "LoadDefReplaceGrp") GUICtrlCreateMenuItem("Set as default group", $ctxt_replace_with) GUICtrlSetOnEvent(-1, "SetDefReplaceGrp") GUICtrlCreateMenuItem("", $ctxt_replace_with) GUICtrlCreateMenuItem("Sort this list", $ctxt_replace_with) GUICtrlSetOnEvent(-1, "SortReplaceList") local $but_replace = GUICtrlCreateButton("Do it!", 105, 0, 45, 22) GUICtrlSetOnEvent(-1, "SearchAndReplace") GUISetCoord(13, 120) $chk_use_regexp = GUICtrlCreateCheckbox("Use Regular Expression", 0, 0, 140, default, Bitor($WS_TABSTOP, $BS_AUTOCHECKBOX, $BS_RIGHT)) GUICtrlSetOnEvent(-1, "SaveUseRegExp") local $lab_rep_limit = GUICtrlCreateLabel("Replacement Limit:", 160, 4, 90) $inp_rep_limit = GUICtrlCreateInput("", 95, -2, 30, 20, $ES_NUMBER) GUICtrlSetOnEvent(-1, "SaveRepLimit") GUISetCoord(5, 140) local $group_ext = GUICtrlCreateGroup("", 0, 0, $width - 10, 46) local $lab_extension = GUICtrlCreateLabel("Extension:", 8, 17, 50) $combo_extension = GUICtrlCreateCombo("", 55, -2, 55, 200) BuildCombo($combo_extension, "extension") local $ctxt_extension = GUICtrlCreateContextMenu($combo_extension) GUICtrlCreateMenuItem("Delete this item", $ctxt_extension) GUICtrlSetOnEvent(-1, "WipeExtensionItem") GUICtrlCreateMenuItem("Wipe this list", $ctxt_extension) GUICtrlSetOnEvent(-1, "WipeExtensionList") GUICtrlCreateMenuItem("", $ctxt_extension) GUICtrlCreateMenuItem("Load default group", $ctxt_extension) GUICtrlSetOnEvent(-1, "LoadDefExtensionGrp") GUICtrlCreateMenuItem("Set as default group", $ctxt_extension) GUICtrlSetOnEvent(-1, "SetDefExtensionGrp") GUICtrlCreateMenuItem("", $ctxt_extension) GUICtrlCreateMenuItem("Sort this list", $ctxt_extension) GUICtrlSetOnEvent(-1, "SortExtensionList") local $but_extension_add = GUICtrlCreateButton("Add", 60, 0, 36, 22) GUICtrlSetOnEvent(-1, "AddExtension") local $but_extension_rem = GUICtrlCreateButton("Remove", 41, 0, 50, 22) GUICtrlSetOnEvent(-1, "RemExtension") local $but_extension_repl = GUICtrlCreateButton("Replace", 55, 0, 50, 22) GUICtrlSetOnEvent(-1, "ReplaceExtension") $chk_match_name = GUICtrlCreateCheckbox("only if name matches", 55, 0, 120) GUICtrlSetOnEvent(-1, "SaveNameMatch") GUISetCoord(5, 189) local $group_handy = GUICtrlCreateGroup("Handy functions.. ", 0, 0, $width - 10, 50) local $but_uppercase = GUICtrlCreateButton("UPPERcase", 8, 20, 75, 22) GUICtrlSetOnEvent(-1, "UpperName") local $but_lowercase = GUICtrlCreateButton("lowercase", 80, 0, 75, 22) GUICtrlSetOnEvent(-1, "LowerName") local $but_capitalize = GUICtrlCreateButton("Capitalize", 80, 0, 70, 22) GUICtrlSetOnEvent(-1, "CapName") local $but_underscores = GUICtrlCreateButton("Under_scores", 75, 0, 85, 22) GUICtrlSetOnEvent(-1, "ConvUnderscores") local $but_dots = GUICtrlCreateButton("D.o.t.s", 90, 0, 55, 22) GUICtrlSetOnEvent(-1, "ConvDots") GUISetCoord(5, 242) $group_handy = GUICtrlCreateGroup("Quick Prefs.. ", 0, 0, $width - 10, 50) $chk_recursive = GUICtrlCreateCheckbox("Run Recursively", 8, 20) GUICtrlSetOnEvent(-1, "SetRecursive") $chk_do_folders = GUICtrlCreateCheckbox("Do Folders", 120, 0) GUICtrlSetOnEvent(-1, "SetDoFolders") $chk_only_folders = GUICtrlCreateCheckbox("Only Folders", 80, 0) GUICtrlSetOnEvent(-1, "SetOnlyFolders") GUISetCoord($width - 72, 260) $but_undo = GUICtrlCreateButton("Undo!", 0, 0, 55, 22) GUICtrlSetOnEvent(-1, "Undo") local $quick_pos = ControlGetPos($mzGUI, "", $group_handy) if IsArray($quick_pos) then $max_height = $quick_pos[1] + $quick_pos[3] + $GROUP_BOTTOM_MARGIN local $dummy_end = GUICtrlCreateGroup("", -9999, -9999) GUICtrlSetState($chk_use_regexp, $use_regexp) GUICtrlSetState($chk_match_name, $match_name) GUICtrlSetState($chk_recursive, $recursive) GUICtrlSetState($chk_do_folders, $do_folders) GUICtrlSetState($chk_only_folders, $only_folders) GUICtrlSetData($inp_rep_limit, $rep_limit) GUICtrlSetState($but_undo, $GUI_DISABLE) SetFolderOnlyChkState() for $i = $group_source to $dummy_end GUICtrlSetResizing($i, $GUI_DOCKALL) next GUICtrlSetResizing($group_source, $GUI_DOCKALL + $GUI_DOCKRIGHT) GUICtrlSetResizing($group_name, $GUI_DOCKALL + $GUI_DOCKRIGHT) GUICtrlSetResizing($group_ext, $GUI_DOCKALL + $GUI_DOCKRIGHT) GUICtrlSetResizing($group_handy, $GUI_DOCKALL + $GUI_DOCKRIGHT) GUICtrlSetResizing($combo_source_folder, $GUI_DOCKALL + $GUI_DOCKRIGHT) GUICtrlSetResizing($combo_file_mask, $GUI_DOCKALL + $GUI_DOCKRIGHT) GUICtrlSetResizing($but_undo, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT + $GUI_DOCKTOP + $GUI_DOCKRIGHT) if $show_tips = $ON then local $tip = " Items inside this folder path will be processed by MangleeZee. " & $lf & _ " You can drag and drop stuff onto this input (folders, files and shortcuts to those)." & $lf & _ " Note: for auto-file mask, hold down (by extension) or (by full name). " GUICtrlSetTip($lab_source_folder, $tip) GUICtrlSetTip($combo_source_folder, $tip) $tip = " MangleeZee will operate on whatever items you specify here. File System Wild Cards are supported. " & $lf & _ ' e.g. for all files, use "*.*" (no quotes), for text files, use "*.txt", and so on. ' & $lf & _ ' To specify files with NO extension, use "*." ' GUICtrlSetTip($lab_file_mask, $tip) GUICtrlSetTip($combo_file_mask, $tip) $tip = " The text to search for (aka. 'match against'). You can use PCRE Regular Expression, " & $lf & _ " and capture groups inside brackets. These captured groups can then be inserted into the " & $lf & _ " replacement string, using back-references. [click the label for a larger input box] " GUICtrlSetTip($lab_search_for, $tip) GUICtrlSetTip($combo_search_for, $tip) $tip = " Replace the matched string with THIS string. Using regular expression, " & $lf & _ " matched groups can be back-referenced with $1 - $9 (or \1 - \9). " & $lf & _ " [click the label for a larger input box] " GUICtrlSetTip($lab_replace_with, $tip) GUICtrlSetTip($combo_replace_with, $tip) GUICtrlSetTip($but_replace, " Click here to perform the Search & Replace.. ") GUICtrlSetTip($chk_use_regexp, " Use standard PCRE regular expressions. Matched grouped text can " & $lf & _ " be inserted using the numbered back-references, $1 - $9 (or \1 - \9). " & $lf & _ " Note: Regexp is case-sensitive (you can override in the expression), normal search & replace is not. ") $tip = " Limit the number of replacements performed. " & $lf & " if empty, this defaults to 0, which is 'no limit'. " GUICtrlSetTip($lab_rep_limit, $tip) GUICtrlSetTip($inp_rep_limit, $tip) $tip = " Add or remove file extensions here. You do not need to add the dot. " GUICtrlSetTip($lab_extension, $tip) GUICtrlSetTip($combo_extension, $tip) GUICtrlSetTip($but_extension_add, " Add the specified extension.. ") GUICtrlSetTip($but_extension_rem, " Remove the specified extension.. ") GUICtrlSetTip($but_extension_repl, " Replace the extension with the specified extension " & $lf & " Remember to set your file mask to the old extension, e.g: *.old ") GUICtrlSetTip($chk_match_name, " Only perform the specified extension mangle IF the name ALSO matches whatever is " & $lf & _ " in your 'Search for:' input (above). Any regexp there will also be parsed (if enabled). ") GUICtrlSetTip($but_capitalize, " Capitalize All The Words Of The Name, Like This Sentence Is. ") GUICtrlSetTip($but_lowercase, " lowercase all the words of the name, like this sentence is. ") GUICtrlSetTip($but_uppercase, " UPPERcase ALL THE WorDS OF THE NAME, LIKE THIS SENTENCE IS. ") GUICtrlSetTip($but_underscores, " Convert_Underscores_to_Spaces. ") GUICtrlSetTip($but_dots, " Convert.D.O.T.S.to.Spaces. ") GUICtrlSetTip($chk_recursive, " Run rename operations on interior folders, and any folders inside " & $lf & _ " those, and any folders inside those, and so on, and so on. BEWARE!!! ") GUICtrlSetTip($chk_do_folders, " Run rename operations on folders (matching the file mask) as well as files. " & $lf & " Be especially mindful when doing this resursively. ") GUICtrlSetTip($chk_only_folders, " Run rename operations ONLY on folders " & $lf & " for some reason.. ") GUICtrlSetTip($but_undo, " Undo the last operation. *phew* (Ctrl+Alt+Z) ") endif CheckSize() if $fade_in = $ON then FadeIn($mzGUI, $fade_speed) else GUISetState(@Sw_Show, $mzGUI) endif $visible = true endfunc func FadeIn($gui, $speed=10) $speed = Int($speed) if $speed < 1 or $speed > 100 then $speed = 10 ; A speed of 100 is deliberately instant, as described in Preferences. if $speed = 100 then WinSetTrans($gui, "", 255) GUISetState(@Sw_Show, $gui) return endif ; Preserve the old speed scale while using elapsed time and smoothstep easing. local $duration = Ceiling(255 / $speed) * 10 local $timer = TimerInit() local $progress, $alpha WinSetTrans($gui, "", 0) GUISetState(@Sw_Show, $gui) do $progress = TimerDiff($timer) / $duration if $progress >= 1 then exitloop $alpha = Int(255 * ($progress * $progress * (3 - (2 * $progress)))) WinSetTrans($gui, "", $alpha) Sleep(10) until false WinSetTrans($gui, "", 255) endfunc func GetPrefs() $x = IniRead($ini_path, $my_name, "x", -1) $y = IniRead($ini_path, $my_name, "y", -1) $width = IniRead($ini_path, $my_name, "width", 410) $height = IniRead($ini_path, $my_name, "height", 244) $min_width = IniRead($ini_path, $my_name, "min_width", 410) $width_magic = 8 $min_height = IniRead($ini_path, $my_name, "min_height", 239) $height_magic = 35 $def_ix = 30 $def_iy = 241 $def_iw = 484 $input_x = IniRead($ini_path, $my_name, "input_x", $def_ix) $input_y = IniRead($ini_path, $my_name, "input_y", $def_iy) $input_width = IniRead($ini_path, $my_name, "input_width", $def_iw) $show_tips = IniReadCheckBoxValue($ini_path, $my_name, "show_tips", $ON) $taskbar_entry = IniReadCheckBoxValue($ini_path, $my_name, "taskbar_entry", $OFF) $always_on_top = IniReadCheckBoxValue($ini_path, $my_name, "always_on_top", $OFF) $max = IniRead($ini_path, $my_name, "max", 1000000) $info_time = IniRead($ini_path, $my_name, "info_time", 3) $explorer_context = IniReadCheckBoxValue($ini_path, $my_name, "explorer_context", $OFF) if $explorer_context = $ON then SetExplorerDirectoryContextMenu($my_name, $explorer_context, $my_name & "..", "", $me_app, $me_app & ",0") if @Error then $explorer_context = $OFF IniWriteCheckBoxValue($ini_path, $my_name, "explorer_context", $explorer_context) endif endif local $i = Detokenize(IniRead($ini_path, $my_name, "log_file", "")) if TestLogFileWritable($i) then $log_file = $i else $log_file = false endif $log_append = IniReadCheckBoxValue($ini_path, $my_name, "log_append", $ON) $rep_limit = IniRead($ini_path, $my_name, "rep_limit", 1) $use_regexp = IniReadCheckBoxValue($ini_path, $my_name, "use_regexp", $OFF) $match_name = IniReadCheckBoxValue($ini_path, $my_name, "match_name", $OFF) $def_source_folder = IniRead($ini_path, $my_name, "def_source_folder", "") $def_file_mask = IniRead($ini_path, $my_name, "def_file_mask", "*.*") $def_search_for = IniRead($ini_path, $my_name, "def_search_for", "|^(..) -|") $def_replace_with = IniRead($ini_path, $my_name, "def_replace_with", "|$1.|") $def_extension = IniRead($ini_path, $my_name, "def_extension", "") $recursive = IniReadCheckBoxValue($ini_path, $my_name, "recursive", $OFF) $do_folders = IniReadCheckBoxValue($ini_path, $my_name, "do_folders", $OFF) $only_folders = IniReadCheckBoxValue($ini_path, $my_name, "only_folders", $OFF) $hover_to_show = IniReadCheckBoxValue($ini_path, $my_name, "hover_to_show", $ON) $hover_sensitivity = Abs(Int(IniRead($ini_path, $my_name, "hover_sensitivity", 10))) $beep = IniReadCheckBoxValue($ini_path, $my_name, "beep", $ON) $fade_in = IniReadCheckBoxValue($ini_path, $my_name, "fade_in", $ON) $fade_speed = Abs(Int(IniRead($ini_path, $my_name, "fade_speed", 10))) if $fade_speed > 100 or $fade_speed < 1 then $fade_speed = 10 IniWrite($ini_path, $my_name, "fade_speed", 10) endif $rename_hidden = IniReadCheckBoxValue($ini_path, $my_name, "rename_hidden", $OFF) $rename_checksum_entries = IniReadCheckBoxValue($ini_path, $my_name, "rename_checksum_entries", $ON) if $rename_checksum_entries <> $ON and $rename_checksum_entries <> $OFF then $rename_checksum_entries = $ON $checksum_extension = NormalizeExtensionList(IniRead($ini_path, $my_name, "checksum_extension", "hash")) if not $checksum_extension or StringLower($checksum_extension) = "unset" then $checksum_extension = "hash" $ignore_files = IniRead($ini_path, $my_name, "ignore_files", "desktop.ini,folder.jpg,thumbs.db") $ignore_files = StringSplit($ignore_files, ",") $garbage_collector = IniRead($ini_path, $my_name, "garbage_collector", "hourly") $reg_url = "https://corz.org/windows/software/mangleezee/mangleezee-licensing.php?app=true" $versioncheck_url = "https://corz.org/inc/versions.php?app=mangleezee" $download_url = "https://corz.org/windows/software/mangleezee/#section-Download" endfunc ; Test whether a log path can receive log output without loss of data. ; Data in: $log_path contains the detokenized candidate path, "" requests ; no log. Reads no globals. Data out: true when an existing file opens ; for append or when a new path passes the creation probe, false ; otherwise. An existing file is left unchanged. Called at start-up and ; on prefs save. func TestLogFileWritable($log_path) if not $log_path then return false if FileExists($log_path) then local $handle = FileOpen($log_path, $FO_APPEND) if $handle = -1 then return false FileClose($handle) return true endif return TestFileWrite($log_path) endfunc func MakeTray() $tray_undo = TrayCreateItem("Undo last operation Ctrl-Alt-Z") TrayItemSetOnEvent(-1, "Undo") TrayItemSetState(-1, $TRAY_DISABLE) TrayCreateItem("") $tray_prefs = TrayCreateItem("Preferences F6") TrayItemSetOnEvent(-1, "DoPrefsGUI") $tray_editini = TrayCreateItem("Edit MangleeZee.ini F7") TrayItemSetOnEvent(-1, "EditIniFile") TrayCreateItem("") $tray_always_on_top = TrayCreateItem("Always On Top") TrayItemSetState(-1, $always_on_top) TrayItemSetOnEvent(-1, "ToggleAlwaysOnTop") $tray_explorer_context = TrayCreateItem("Explorer Context Menu") TrayItemSetState(-1, $explorer_context) TrayItemSetOnEvent(-1, "AddToExplorerContext") TrayCreateItem("") if $log_file then $tray_viewlog = TrayCreateItem("View Log File.. F8") TrayItemSetOnEvent(-1, "ViewLogFile") TrayCreateItem("") endif TrayCreateItem("About " & $my_name) TrayItemSetOnEvent(-1, "EventDoAboutBox") TrayCreateItem("") $tray_quit = TrayCreateItem("Quit Alt-F4/Esc") TrayItemSetOnEvent(-1, "TrayQuit") TraySetClick(8) TraySetState(1) TraySetIcon($me_app, 0) endfunc func GetDroppedItem() local $new_mask = false local $import_item = false if @Gui_DragId = -1 then if IsDir(@Gui_DragFile) then $import_item = @Gui_DragFile else if GetExtension(@Gui_DragFile) = "lnk" then local $lnk_arr = FileGetShortcut(@Gui_DragFile) if IsDir($lnk_arr[0]) then $import_item = $lnk_arr[0] else $import_item = GetParent($lnk_arr[0]) if _IsPressed("10") then $new_mask = "*." & GetExtension($lnk_arr[0]) if _IsPressed("11") then $new_mask = BaseName($lnk_arr[0]) endif else $import_item = GetParent(@Gui_DragFile) if _IsPressed("10") then $new_mask = "*." & GetExtension(@Gui_DragFile) if _IsPressed("11") then $new_mask = BaseName(@Gui_DragFile) endif endif endif if $import_item then AddStringToCombo($combo_source_folder, "source_folder", $import_item) BuildCombo($combo_source_folder, "source_folder") SelectComboString($combo_source_folder, $import_item) if $new_mask then if not InPref("file_mask", $new_mask) then ControlCommand($mzGUI, "", $combo_file_mask, "AddString", $new_mask) SelectComboString($combo_file_mask, $new_mask) endif endif endfunc func InputSearchString() LaunchInput($combo_search_for, "search_x", "search_y", "search_width", " Search for : ", " Enter the new search string..", "search_for") GUICtrlSetState($combo_search_for, $GUI_FOCUS) endfunc func InputReplaceString() LaunchInput($combo_replace_with, "replace_x", "replace_y", "replace_width", " Replace with : ", " Enter the new replacement string..", "replace_with") GUICtrlSetState($combo_replace_with, $GUI_FOCUS) endfunc func LaunchInput(byref $control, $x_prefname, $y_prefname, $width_prefname, $title_str, $text_str, $combo_str) local $size_array = WinGetPos($my_name) local $def = GUICtrlRead($control) local $sx = $size_array[0] + 10 local $sy = $size_array[1] + 24 local $sw = $size_array[2] - 24 local $tmp_x, $tmp_y, $tmp_w if _IsPressed("10") then IniDelete($ini_path, $my_name, $x_prefname) IniDelete($ini_path, $my_name, $y_prefname) else $tmp_x = IniRead($ini_path, $my_name, $x_prefname, "") if $tmp_x <> "" then $sx = $tmp_x $tmp_y = IniRead($ini_path, $my_name, $y_prefname, "") if $tmp_y <> "" then $sy = $tmp_y $tmp_w = IniRead($ini_path, $my_name, $width_prefname, "") if $tmp_w <> "" then $sw = $tmp_w endif ; local $custom_input = CorzInputBox($title_str, $text_str, $def, "", $sw, 85, $sx, $sy, 0, $mzGUI) local $custom_input = CorzInputBox($title_str, $text_str, $def, "", $sw, 85, $sx, $sy, $mzGUI) if not IsArray($custom_input) then return false $tmp_x = $custom_input[1] $tmp_y = $custom_input[2] $tmp_w = $custom_input[3] $custom_input = $custom_input[0] if $tmp_x <> 0 then IniWrite($ini_path, $my_name, $x_prefname, $tmp_x) if $tmp_y <> 0 then IniWrite($ini_path, $my_name, $y_prefname, $tmp_y) IniWrite($ini_path, $my_name, $width_prefname, $tmp_w) if $custom_input then AddStringToCombo($control, $combo_str, $custom_input) SelectComboString($control, $custom_input) endif endfunc ; func CorzInputBox($ipb_title, $prompt, $default = "", $pass = 0, $ib_w = 400, $ib_h = 84, $ib_x = -1, $ib_y = -1, $timeout = 0, $whandle = "", $style = -1, $exstyle = -1) func CorzInputBox($ipb_title, $prompt, $default="", $pass=0, $ib_w=400, $ib_h=84, $ib_x=-1, $ib_y=-1, $whandle="", $style=-1, $exstyle=-1) DialogOpen($mzGUI) local $last_event_mode = AutoItSetOption("GUIOnEventMode", 0) local $coord = AutoItSetOption("GUICoordMode", 1) local $min_w = 200, $x_coord = 0, $y_coord = 0 local $inputstyle = $ES_AUTOHSCROLL if $style = -1 then $style = Bitor($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_SIZEBOX) if $pass <> 0 then $inputstyle = Bitor($ES_AUTOHSCROLL, $ES_PASSWORD) local $ib_gui = GUICreate($ipb_title, $ib_w, $ib_h, $ib_x, $ib_y, $style, $exstyle, $whandle) local $lab_prompt = GUICtrlCreateLabel($prompt, 3, 4, $ib_w - 30, 22) GUICtrlSetFont(-1, default, 800) local $inp_myid = GUICtrlCreateInput($default, 70, $ib_h - 26, $ib_w - 125, 24, $inputstyle) GUICtrlSetState(-1, $GUI_FOCUS) GUICtrlSetFont(-1, 12, 400, "", "Lucida Console") local $but_cancel = GUICtrlCreateButton("Cancel", 5, $ib_h - 26, 60, 24) GUICtrlSetState(-1, $GUI_ONTOP) local $but_ok = GUICtrlCreateButton("OK", $ib_w - 45, $ib_h - 26, 40, 24, $BS_DEFPUSHBUTTON) GUICtrlSetState(-1, $GUI_ONTOP) GUICtrlSetResizing($lab_prompt, $GUI_DOCKALL) GUICtrlSetResizing($but_ok, $GUI_DOCKSTATEBAR + $GUI_DOCKWIDTH) GUICtrlSetResizing($but_cancel, $GUI_DOCKSTATEBAR + $GUI_DOCKWIDTH) GUICtrlSetResizing($inp_myid, $GUI_DOCKSTATEBAR + $GUI_DOCKLEFT + $GUI_DOCKRIGHT) GUISetState(@Sw_Show, $ib_gui) WinMove($ipb_title, "", default, default, $ib_w, $ib_h) local $msg, $size_array, $return while 1 $msg = GUIGetMsg() switch $msg case $GUI_EVENT_RESIZED $size_array = WinGetPos($ipb_title) if not IsArray($size_array) then continueloop if $size_array[2] < $min_w then WinMove($ipb_title, "", default, default, $min_w, $ib_h) if $size_array[3] <> $ib_h then WinMove($ipb_title, "", default, default, $min_w, $ib_h) case $GUI_EVENT_CLOSE, $but_cancel $return = "" exitloop case $but_ok $return = GUICtrlRead($inp_myid) exitloop endswitch wend $size_array = WinGetPos($ipb_title) if IsArray($size_array) then if $size_array[0] <> $ib_x then $x_coord = $size_array[0] if $size_array[1] <> $ib_y then $y_coord = $size_array[1] if $size_array[2] <> $ib_w then $width = $size_array[2] endif AutoItSetOption("GUIOnEventMode", $last_event_mode) AutoItSetOption("GUICoordMode", $coord) if $whandle then GUIswitch($whandle) GUIDelete($ib_gui) DialogClose($mzGUI) local $ret[4] = [$return, $x_coord, $y_coord, $width] return $ret endfunc func GrabComboPref($ini_prefname) local $tmp = IniRead($ini_path, $my_name, $ini_prefname, "") if not $tmp then return "" $tmp = StringStripWS(StringReplace($tmp, "||", "|"), 3) while StringRight($tmp, 1) = "|" $tmp = StringTrimRight($tmp, 1) wend while StringLeft($tmp, 1) = "|" $tmp = StringTrimLeft($tmp, 1) wend return $tmp endfunc func BuildCombo(byref $control, $ini_prefname) local $data = GrabComboPref($ini_prefname) $data = StringSplit($data, "|") GUICtrlSetData($control, "") if $data[0] then for $i = 1 to $data[0] if $data[$i] then ControlCommand($mzGUI, "", $control, "AddString", $data[$i]) endif next SelectComboString($control, $data[$data[0]]) endif endfunc func SelectComboString(byref $control, $selection) local $index = _GUICtrlComboBox_FindStringExact($control, $selection) if $index <> -1 then _GUICtrlComboBox_SetCurSel($control, $index) endfunc func InPref($ini_prefname, $string) if not $string then return local $tmp = GrabComboPref($ini_prefname) if not $tmp then return if StringInStr("|" & $tmp & "|", "|" & $string & "|") then return true endfunc func LoadDefSourceFolderGrp() LoadDefGroup("def_source_folder", "", $combo_source_folder, "source_folder") endfunc func SetDefSourceFolderGrp() SetDefGroup("def_source_folder", "source_folder") endfunc func LoadDefFileMaskGrp() LoadDefGroup("def_file_mask", "*.*", $combo_file_mask, "file_mask") endfunc func SetDefFileMaskGrp() SetDefGroup("def_file_mask", "file_mask") endfunc func LoadDefSearchForGrp() LoadDefGroup("def_search_for", "|^(..) -|", $combo_search_for, "search_for") endfunc func SetDefSearchForGrp() SetDefGroup("def_search_for", "search_for") endfunc func LoadDefReplaceGrp() LoadDefGroup("def_replace_with", "*.*", $combo_replace_with, "replace_with") endfunc func SetDefReplaceGrp() SetDefGroup("def_replace_with", "replace_with") endfunc func LoadDefExtensionGrp() LoadDefGroup("def_extension", "*.*", $combo_extension, "extension") endfunc func SetDefExtensionGrp() SetDefGroup("def_extension", "extension") endfunc func SetDefGroup($def_grp_pref, $combo_pref) local $i = GrabComboPref($combo_pref) if $i = "" then return false local $def_grp = "|" & $i & "|" IniWrite($ini_path, $my_name, $def_grp_pref, $def_grp) endfunc func LoadDefGroup($def_grp_pref, $default, $combo, $combo_pref) local $i = IniRead($ini_path, $my_name, $def_grp_pref, $default) IniWrite($ini_path, $my_name, $combo_pref, $i) BuildCombo($combo, $combo_pref) endfunc func SortSourceFolderList() SortComboPrefList($combo_source_folder, "source_folder") endfunc func SortFileMaskList() SortComboPrefList($combo_file_mask, "file_mask") endfunc func SortSearchForList() SortComboPrefList($combo_search_for, "search_for") endfunc func SortReplaceList() SortComboPrefList($combo_replace_with, "replace_with") endfunc func SortExtensionList() SortComboPrefList($combo_extension, "extension") endfunc func WipeSourceFolderList() WipeComboPrefList($combo_source_folder, "source_folder") endfunc func WipeSourceFolderItem() WipeSingleComboItem($combo_source_folder, "source_folder") endfunc func WipeFileMaskList() WipeComboPrefList($combo_file_mask, "file_mask") endfunc func WipeFileMaskItem() WipeSingleComboItem($combo_file_mask, "file_mask") endfunc func WipeSearchForList() WipeComboPrefList($combo_search_for, "search_for") endfunc func WipeSearchForItem() WipeSingleComboItem($combo_search_for, "search_for") endfunc func WipeReplaceItem() WipeSingleComboItem($combo_replace_with, "replace_with") endfunc func WipeReplaceList() WipeComboPrefList($combo_replace_with, "replace_with") endfunc func WipeExtensionItem() WipeSingleComboItem($combo_extension, "extension") endfunc func WipeExtensionList() WipeComboPrefList($combo_extension, "extension") endfunc func WipeSingleComboItem(byref $control, $ini_prefname) if GUICtrlRead($control) == "" then return local $tmp = "|" & GrabComboPref($ini_prefname) & "|" $tmp = StringReplace($tmp, "|" & GUICtrlRead($control) & "|", "|") IniWrite($ini_path, $my_name, $ini_prefname, $tmp) BuildCombo($control, $ini_prefname) endfunc func WipeComboPrefList(byref $control, $ini_prefname) local $tmp if _IsPressed("10") then $tmp = GUICtrlRead($control) IniWrite($ini_path, $my_name, $ini_prefname, "") BuildCombo($control, $ini_prefname) if $tmp then ControlCommand($mzGUI, "", $control, "AddString", $tmp) SelectComboString($control, $tmp) endif endfunc func SortComboPrefList(byref $control, $ini_prefname) if GUICtrlRead($control) == "" then return local $tmp = "|" & GrabComboPref($ini_prefname) & "|" local $array = StringSplit($tmp, "|") $array = BubbleSort($array) $tmp = "|" for $i = 1 to $array[0] if $i then $tmp &= $array[$i] & "|" next IniWrite($ini_path, $my_name, $ini_prefname, $tmp) BuildCombo($control, $ini_prefname) endfunc func SetComboToCurrent(byref $control, $ini_prefname) if GUICtrlRead($control) == "" then return local $tmp = "|" & GrabComboPref($ini_prefname) & "|" $tmp = StringReplace($tmp, "|" & GUICtrlRead($control) & "|", "|") IniWrite($ini_path, $my_name, $ini_prefname, $tmp & GUICtrlRead($control) & "|") BuildCombo($control, $ini_prefname) endfunc func AddStringToCombo(byref $control, $ini_prefname, $new_str) if IntSaveStringToComboPref($ini_prefname, $new_str) then ControlCommand($mzGUI, "", $control, "AddString", $new_str) endif if $new_str then SelectComboString($control, $new_str) endfunc func IntSaveStringToComboPref($ini_prefname, $data) if not $data then return false local $tmp = GrabComboPref($ini_prefname) $tmp = "|" & $tmp & "|" if not StringInStr($tmp, "|" & $data & "|") then if IniWrite($ini_path, $my_name, $ini_prefname, $tmp & $data & "|") then return true endif endfunc func RemExtension() AddStringToCombo($combo_extension, "extension", GUICtrlRead($combo_extension)) if $match_name then ReadSearchReplaceCombos() MangleBaby("-x") endfunc func AddExtension() AddStringToCombo($combo_extension, "extension", GUICtrlRead($combo_extension)) if $match_name then ReadSearchReplaceCombos() MangleBaby("+x") endfunc func ReplaceExtension() AddStringToCombo($combo_extension, "extension", GUICtrlRead($combo_extension)) if $match_name then ReadSearchReplaceCombos() MangleBaby("xx") endfunc func SearchAndReplace() $add_search = false $add_replace = false ReadSearchReplaceCombos() local $tmp_replace = $replace_with CheckCountParams($replace_with, "@count") if MangleBaby("sr") then if $add_search then AddStringToCombo($combo_search_for, "search_for", $search_for) if $add_replace then AddStringToCombo($combo_replace_with, "replace_with", $tmp_replace) endif endfunc func ReadSearchReplaceCombos() local $i = GUICtrlRead($combo_search_for) if $search_for <> $i then $search_for = $i if not InPref("search_for", $search_for) then $add_search = true endif $i = GUICtrlRead($combo_replace_with) if $replace_with <> $i then $replace_with = $i if not InPref("replace_with", $replace_with) then $add_replace = true endif endfunc func CapName() MangleBaby("Cap") endfunc func LowerName() MangleBaby("low") endfunc func UpperName() MangleBaby("UP") endfunc func ConvUnderscores() MangleBaby("_") endfunc func ConvDots() MangleBaby(".") endfunc func MangleBaby($action_type=0) local $i = GUICtrlRead($combo_source_folder) if FileExists($i) and IsDir($i) then $source_folder = $i AddStringToCombo($combo_source_folder, "source_folder", $i) else WipeSingleComboItem($combo_source_folder, "source_folder") InfoTitle("Source folder does not exist!", $info_time * 2) return endif InfoTitle("Working..", $info_time * 10000) DialogOpen($mzGUI) $file_mask = GUICtrlRead($combo_file_mask) if not $file_mask then $file_mask = "*.*" if not InPref("file_mask", $file_mask) then AddStringToCombo($combo_file_mask, "file_mask", $file_mask) if $file_mask = "*.*" then SelectComboString($combo_file_mask, "*.*") $extension = GUICtrlRead($combo_extension) local $dont_recurse = true if $recursive = $ON then $dont_recurse = false local $file_array, $folder_array InfoTitle("Reading Directory..", $info_time * 10000) if $only_folders = $ON and $do_folders = $ON then else $file_array = RecurseDirMZ($source_folder, $file_mask, $dont_recurse, "", false, $max) endif if $do_folders = $ON then $folder_array = RecurseDirMZ($source_folder, $file_mask, $dont_recurse, "", true, $max, true) if IsArray($folder_array) then if $folder_array[1] = $source_folder then _ArrayDelete($folder_array, 1) $folder_array[0] -= 1 if $folder_array[0] = 0 then DialogClose($mzGUI) return false endif endif _ArrayReverse($folder_array, 1) if IsArray($file_array) and $only_folders = $OFF then local $a_tot = _ArrayConcatenate($file_array, $folder_array) if $a_tot then $file_array[0] = $a_tot - 1 $folder_array = 0 else DialogClose($mzGUI) return false endif else if IsArray($folder_array) then $file_array = $folder_array endif endif endif endif if not IsArray($file_array) then InfoTitle("No matching files! (check the file mask)", $info_time * 3) DoLog(@Hour & ":" & @Min & ":" & @Sec & ": " & "No files matching current file mask, try '*.*'." & $lf, $log_append) DialogClose($mzGUI) return endif $rename_hidden = IniReadCheckBoxValue($ini_path, $my_name, "rename_hidden", $OFF) $rename_checksum_entries = IniReadCheckBoxValue($ini_path, $my_name, "rename_checksum_entries", $ON) if $rename_checksum_entries <> $ON and $rename_checksum_entries <> $OFF then $rename_checksum_entries = $ON $checksum_extension = NormalizeExtensionList(IniRead($ini_path, $my_name, "checksum_extension", "hash")) if not $checksum_extension or StringLower($checksum_extension) = "unset" then $checksum_extension = "hash" $ignore_files = IniRead($ini_path, $my_name, "ignore_files", "desktop.ini,folder.jpg,.desktop,thumbs.db") $ignore_files = StringSplit($ignore_files, ",") InfoTitle("Renaming..", $info_time * 10000) local $done_files = 0 for $mz = 1 to $file_array[0] local $new_file = "" local $this_command = "File mask (" & $file_mask & "): " if StringLen($this_command) > 50 then $this_command &= $lf local $moved = false local $file = $file_array[$mz] local $parent = GetParent($file) local $filename = BaseName($file) if InArray($ignore_files, $filename) then continueloop if $rename_hidden = $OFF and StringInStr(FileGetAttrib($file), "H") then continueloop if not IsDir($file) and HasChecksumExtension($file) then continueloop if StringInStr($filename, ".") then local $ext = "." & GetExtension($filename) local $no_ext = RemoveExtension($filename) else $ext = "" $no_ext = $filename endif if IsDir($file) then $no_ext = $filename $ext = "" endif switch $action_type case "sr" if not $search_for then DialogClose($mzGUI) return endif $rep_limit = GUICtrlRead($inp_rep_limit) if $use_regexp = $ON then $this_command &= "Using Regexp: " local $rp_tmp = StringRegExpReplace($no_ext, $search_for, $replace_with, $rep_limit) else $rp_tmp = StringReplace($no_ext, $search_for, $replace_with, $rep_limit) endif local $move_to = $parent & "\" & $rp_tmp & $ext if StringInStr($move_to, "@") then $move_to = DetokenizeReplaceString($move_to, $file) $moved = ItemMove($file, $move_to, 0, $parent, $filename) if $moved then $new_file = $move_to $done_files += 1 endif $this_command &= "Search for '" & $search_for & "', replace with '" & $replace_with & "': " & $lf case "+x" $move_to = $file & "." & $extension if $match_name = $ON then $this_command &= "Matching name against '" & $search_for & "': " if MatchFileName($no_ext) then $moved = ItemMove($file, $move_to, 0, $parent, $filename) else $moved = ItemMove($file, $move_to, 0, $parent, $filename) endif if $moved then $new_file = $move_to $done_files += 1 endif $this_command &= "Add extension '" & $extension & "'" & $lf case "xx" $move_to = $parent & "\" & $no_ext & "." & $extension if $match_name = $ON then $this_command &= "Matching name against '" & $search_for & "': " if MatchFileName($no_ext) then $moved = ItemMove($file, $move_to, 0, $parent, $filename) else $moved = ItemMove($file, $move_to, 0, $parent, $filename) endif if $moved then $new_file = $move_to $done_files += 1 endif $this_command &= "Replace extension '" & $extension & "'" & $lf case "-x" if GetExtension($file) = $extension then $move_to = RemoveExtension($file) if $match_name = $ON then $this_command &= "Matching name against '" & $search_for & "': " if MatchFileName($no_ext) then $moved = ItemMove($file, $move_to, 0, $parent, $filename) else $moved = ItemMove($file, $move_to, 0, $parent, $filename) endif endif if $moved then $new_file = $move_to $done_files += 1 endif $this_command &= "Remove extension '" & $extension & "': " & $lf case "low" $move_to = $parent & "\" & StringLower($no_ext & $ext) $moved = ItemMove($file, $move_to, 1, $parent, $filename) if $moved then $new_file = $move_to $done_files += 1 endif $this_command &= "lowercase names: " & $lf case "UP" $move_to = $parent & "\" & StringUpper($no_ext & $ext) $moved = ItemMove($file, $move_to, 1, $parent, $filename) if $moved then $new_file = $move_to $done_files += 1 endif $this_command &= "UPPERcase names: " & $lf case "Cap" $move_to = StringReplace($no_ext, "(", "( ") $move_to = StringReplace($move_to, "[", "[ ") $move_to = StringReplace($move_to, "{", "{ ") $move_to = StringReplace($move_to, ".", ". ") $move_to = $parent & "\" & Proper($move_to) & StringLower($ext) $move_to = StringReplace($move_to, "( ", "(") $move_to = StringReplace($move_to, "[ ", "[") $move_to = StringReplace($move_to, "{ ", "{") $move_to = StringReplace($move_to, ". ", ".") $moved = ItemMove($file, $move_to, 1, $parent, $filename) if $moved then $new_file = $move_to $done_files += 1 endif $this_command &= "Capitalize names: " & $lf case "_" if StringInStr($no_ext, "_") then $rp_tmp = StringReplace($no_ext, "_", " ") $move_to = $parent & "\" & $rp_tmp & $ext $moved = ItemMove($file, $move_to, 0, $parent, $filename) if $moved then $new_file = $move_to $done_files += 1 endif endif $this_command &= "Replace underscores with spaces: " & $lf case "." if StringInStr($no_ext, ".") then $rp_tmp = StringReplace($no_ext, ".", " ") $move_to = $parent & "\" & $rp_tmp & $ext $moved = ItemMove($file, $move_to, 1, $parent, $filename) if $moved then $new_file = $move_to $done_files += 1 endif endif $this_command &= "Replace dots with spaces: " & $lf endswitch if $new_file then $count += 1 $file_array[$mz] &= "|" & $new_file else $file_array[$mz] = "" endif next if $done_files > 0 then local $title_msg = $done_files & " Names Changed" UpdateRenameReferences($file_array) $undos = $file_array ToggleEnableUndo(true) else $title_msg = "Nothing Done!" endif if $log_file then local $log_str = @Hour & ":" & @Min & ":" & @Sec & ": " & $this_command & $lf if $done_files > 0 then $log_str &= ChangeArrayToLogString($file_array) else $log_str &= "Nothing Done!" & $lf endif DoLog($log_str, $log_append) endif DialogClose($mzGUI) InfoTitle($title_msg) if $done_files > 0 then return true endfunc func ItemMove($from, $to, $overwrite, $my_parent="", $my_filename="") if IsNumber($from) then return false if $from == $to then return false local $moved = false if not $my_parent then $my_parent = GetParent($from) $my_filename = BaseName($from) endif local $tmp_name = "" local $rnd_len = StringLen($my_filename) local $tn_1 = StringMid("!MANGLETMP!!MANGLETMP!!MANGLETMP!!MANGLETMP!!MANGLETMP!!MANGLETMP!!MANGLETMP!", 1, $rnd_len) local $tn_2 = StringMid("a1b2c3d4e5f6g7h8i9j0k9l8m7n6o5p4q3r2s1t2u3v4w5x6y7z8", 1, $rnd_len) select case not FileExists($my_parent & "\" & $tn_1) $tmp_name = $my_parent & "\" & $tn_1 case not FileExists($my_parent & "\" & $tn_2) $tmp_name = $my_parent & "\" & $tn_2 endselect if not $tmp_name then return false if IsDir($from) then local $tmpmoved = DirMove($from, $tmp_name, $overwrite) if $tmpmoved then $moved = DirMove($tmp_name, $to, $overwrite) if not $moved then $tmpmoved = DirMove($tmp_name, $from, $overwrite) if not $tmpmoved then $not_replaced &= "The DIRECTorY: " & $my_filename & "was not renamed due to a naming conflict error." & $lf endif endif endif else $tmpmoved = FileMove($from, $tmp_name, $overwrite) if $tmpmoved then $moved = FileMove($tmp_name, $to, $overwrite) if not $moved then $tmpmoved = FileMove($tmp_name, $from, $overwrite) if not $tmpmoved then $not_replaced &= "The FILE: " & $my_filename & "was not renamed due to a naming conflict error." & $lf endif endif endif endif return $moved endfunc ; Update each related checksum or playlist once after the complete rename batch. ; Checksum discovery reaches the volume root; playlist discovery stops at the source folder. func UpdateRenameReferences($changes_array) if $rename_checksum_entries <> $ON then return if not IsArray($changes_array) then return local $reference_files = ObjCreate("Scripting.Dictionary") local $playlist_folders = ObjCreate("Scripting.Dictionary") local $filtered_changes[$changes_array[0] + 1] local $filtered_count = 0 $reference_files.CompareMode = 1 $playlist_folders.CompareMode = 1 for $i = 1 to $changes_array[0] if not StringInStr($changes_array[$i], "|") then continueloop local $change = StringSplit($changes_array[$i], "|", 2) if UBound($change) <> 2 or HasChecksumExtension($change[0]) then continueloop $filtered_count += 1 $filtered_changes[$filtered_count] = $changes_array[$i] CollectRenameReferenceFiles($reference_files, $playlist_folders, $change[0], $change[1]) next if not $filtered_count then return $filtered_changes[0] = $filtered_count for $playlist_folder in $playlist_folders.Keys() CollectPlaylistReferenceFiles($reference_files, $playlist_folder) next for $reference_file in $reference_files.Keys() UpdateReferenceFile($reference_file, $filtered_changes, $reference_files.Item($reference_file)) next RenameChecksumSidecars($filtered_changes) endfunc func HasChecksumExtension($file) local $file_extension = GetExtension($file) if not $file_extension then return false local $extensions = StringSplit($checksum_extension, ",", 2) for $extension in $extensions if $file_extension = $extension then return true next return false endfunc func RenameChecksumSidecars($changes_array) local $extensions = StringSplit($checksum_extension, ",", 2) for $i = 1 to $changes_array[0] if not StringInStr($changes_array[$i], "|") then continueloop local $change = StringSplit($changes_array[$i], "|", 2) if UBound($change) <> 2 or IsDir($change[1]) then continueloop for $extension in $extensions local $old_sidecar = GetParent($change[0]) & "\" & CleanName($change[0]) & "." & $extension local $new_sidecar = GetParent($change[1]) & "\" & CleanName($change[1]) & "." & $extension RenameChecksumSidecar($old_sidecar, $new_sidecar) RenameChecksumSidecar($change[0] & "." & $extension, $change[1] & "." & $extension) next next endfunc func RenameChecksumSidecar($from, $to) if $from == $to or not FileExists($from) then return false local $case_only = ($from = $to and not ($from == $to)) if FileExists($to) and not $case_only then return false return ItemMove($from, $to, $case_only) endfunc func CollectRenameReferenceFiles(byref $reference_files, byref $playlist_folders, $from, $to) local $from_parent = NormalizeFolderPath(GetParent($from)) local $root = ResolveAndNormalizePath($source_folder) local $scan_dir = $from_parent local $source_prefix = $root if StringRight($source_prefix, 1) <> "\" then $source_prefix &= "\" do CollectChecksumReferenceFiles($reference_files, $scan_dir, $from, $to, $scan_dir = $from_parent) local $in_source = ($scan_dir = $root or StringLeft($scan_dir, StringLen($source_prefix)) = $source_prefix) if $in_source and not $playlist_folders.Exists($scan_dir) then $playlist_folders.Add($scan_dir, true) local $plain_scan_dir = StripLongPathPrefix($scan_dir) if StringRegExp($plain_scan_dir, "(?i)^[a-z]:\\$") or StringRegExp($plain_scan_dir, "^\\\\[^\\]+\\[^\\]+\\?$") then exitloop local $parent = NormalizeFolderPath(GetParent($scan_dir)) if $parent = $scan_dir then exitloop $scan_dir = $parent until false endfunc func NormalizeFolderPath($folder) if StringRegExp(StripLongPathPrefix($folder), "(?i)^[a-z]:$") then $folder &= "\" return ResolveAndNormalizePath($folder) endfunc func NormalizeExtensionList($extension_list) local $extensions = StringSplit($extension_list, ",", 2) local $normalized = "" for $extension in $extensions $extension = StringRegExpReplace(StringStripWS($extension, 3), "^\.+", "") if not $extension or StringLower($extension) = "unset" then continueloop if $normalized then $normalized &= "," $normalized &= $extension next return $normalized endfunc func CollectChecksumReferenceFiles(byref $reference_files, $folder, $from, $to, $item_folder) local $folder_prefix = $folder if StringRight($folder_prefix, 1) <> "\" then $folder_prefix &= "\" local $extensions = StringSplit($checksum_extension, ",", 2) for $extension in $extensions local $folder_checksum = $folder_prefix & BaseName($folder) & "." & $extension if FileExists($folder_checksum) then AddReferenceFile($reference_files, $folder_checksum, "checksum") if not $item_folder then continueloop local $old_checksum = $folder_prefix & CleanName($from) & "." & $extension local $new_checksum = $folder_prefix & CleanName($to) & "." & $extension if FileExists($old_checksum) then AddReferenceFile($reference_files, $old_checksum, "checksum") if FileExists($new_checksum) then AddReferenceFile($reference_files, $new_checksum, "checksum") next endfunc func CollectPlaylistReferenceFiles(byref $reference_files, $folder) local $types[3] = ["m3u", "m3u8", "pls"] for $type in $types local $search = FileFindFirstFile($folder & "\*." & $type) if $search = -1 then continueloop while true local $name = FileFindNextFile($search) if @Error then exitloop AddReferenceFile($reference_files, $folder & "\" & $name, $type) wend FileClose($search) next endfunc func AddReferenceFile(byref $reference_files, $reference_file, $type) if not $reference_files.Exists($reference_file) then $reference_files.Add($reference_file, $type) endfunc func ReferenceFileApplies($reference_file, $from, $to, $type) local $reference_folder = NormalizeFolderPath(GetParent($reference_file)) local $from_parent = NormalizeFolderPath(GetParent($from)) local $root = ResolveAndNormalizePath($source_folder) local $source_prefix = $root if StringRight($source_prefix, 1) <> "\" then $source_prefix &= "\" local $inside_source = ($reference_folder = $root or StringLeft($reference_folder, StringLen($source_prefix)) = $source_prefix) local $reference_prefix = $reference_folder if StringRight($reference_prefix, 1) <> "\" then $reference_prefix &= "\" local $is_ancestor = ($reference_folder = $from_parent or _ StringLeft($from_parent, StringLen($reference_prefix)) = $reference_prefix) if not $is_ancestor then return false if $type <> "checksum" and not $inside_source then return false if $type <> "checksum" then return true local $stem = CleanName($reference_file) if $stem = BaseName($reference_folder) then return true if $reference_folder <> $from_parent then return false return ($stem = CleanName($from) or $stem = CleanName($to)) endfunc func UpdateReferenceFile($reference_file, $changes_array, $type) local $applicable_changes[$changes_array[0] + 1][2] local $applicable_count = 0 for $i = 1 to $changes_array[0] if not StringInStr($changes_array[$i], "|") then continueloop local $change = StringSplit($changes_array[$i], "|", 2) if UBound($change) <> 2 then continueloop if not ReferenceFileApplies($reference_file, $change[0], $change[1], $type) then continueloop $applicable_count += 1 $applicable_changes[$applicable_count][0] = $change[0] $applicable_changes[$applicable_count][1] = $change[1] next if not $applicable_count then return false local $encoding = FileGetEncoding($reference_file) if $encoding < 0 then $encoding = 0 local $handle = FileOpen($reference_file, $FO_READ + $encoding) if $handle = -1 then return false local $contents = FileRead($handle) FileClose($handle) local $lines = StringSplit($contents, @LF, 1) local $changed = false local $updated = "" for $i = 1 to $lines[0] local $line = $lines[$i] local $cr = "" if StringRight($line, 1) = @Cr then $line = StringTrimRight($line, 1) $cr = @Cr endif local $new_line = $line for $j = 1 to $applicable_count $new_line = UpdateReferenceLine($new_line, $reference_file, _ $applicable_changes[$j][0], $applicable_changes[$j][1], $type) if @Extended then $changed = true next $updated &= $new_line & $cr if $i < $lines[0] then $updated &= @LF next if not $changed then return false ; Write beside the original, then replace it, so a failed write cannot leave ; a truncated checksum or playlist file behind. local $temp_file = $reference_file & ".mangleezee-" & @AutoItPid & ".tmp" if FileExists($temp_file) then FileDelete($temp_file) $handle = FileOpen($temp_file, $FO_OVERWRITE + $encoding) if $handle = -1 then return false local $written = FileWrite($handle, $updated) FileClose($handle) if not $written then FileDelete($temp_file) return false endif if not FileMove($temp_file, $reference_file, 1) then FileDelete($temp_file) return false endif return true endfunc func UpdateReferenceLine($line, $reference_file, $from, $to, $type) local $parts, $replacement switch $type case "checksum" ; Checksum files may contain any supported format or metadata layout. $replacement = StringReplace($line, BaseName($from), BaseName($to)) if @Extended then return SetExtended(1, $replacement) case "pls" ; Only FileN values are filesystem references; TitleN is display text. $parts = StringRegExp($line, "(?i)^([ \t]*File[0-9]+[ \t]*=[ \t]*)(.*)$", 1) if IsArray($parts) then $replacement = RenameReferenceEntry($parts[1], $reference_file, $from, $to) if @Extended then return SetExtended(1, $parts[0] & $replacement) endif case else ; m3u / m3u8 if $line <> "" and StringLeft(StringStripWS($line, 1), 1) <> "#" then $replacement = RenameReferenceEntry($line, $reference_file, $from, $to) if @Extended then return SetExtended(1, $replacement) endif endswitch return SetExtended(0, $line) endfunc ; Return an entry with the renamed path, setting @extended when it matched. ; Comparisons are case-insensitive because these are Windows filesystem paths. func RenameReferenceEntry($entry, $reference_file, $from, $to) if not $entry or StringRegExp($entry, "(?i)^[a-z][a-z0-9+.-]*://") then return SetExtended(0, $entry) local $quoted = StringLen($entry) > 1 and StringLeft($entry, 1) = '"' and StringRight($entry, 1) = '"' local $path_entry = $entry if $quoted then $path_entry = StringTrimLeft(StringTrimRight($path_entry, 1), 1) local $base = GetParent($reference_file) local $resolved = StripLongPathPrefix(ResolveAndNormalizePath(StringReplace($path_entry, "/", "\"), $base)) local $old_path = StripLongPathPrefix(ResolveAndNormalizePath($from)) local $new_path = StripLongPathPrefix(ResolveAndNormalizePath($to)) local $is_exact = ($resolved = $old_path) local $is_child = StringLeft($resolved, StringLen($old_path) + 1) = $old_path & "\" if not $is_exact and not $is_child then return SetExtended(0, $entry) local $new_entry if $is_exact and StringRight($path_entry, StringLen(BaseName($old_path))) = BaseName($old_path) then $new_entry = StringTrimRight($path_entry, StringLen(BaseName($old_path))) & BaseName($new_path) else local $new_resolved = $new_path & StringTrimLeft($resolved, StringLen($old_path)) if StringLeft($path_entry, 2) = "\\" or StringMid($path_entry, 2, 1) = ":" then $new_entry = $new_resolved else $new_entry = _PathGetRelative($base, $new_resolved) if StringLeft($path_entry, 2) <> "" and StringLeft($new_entry, 2) = "" then $new_entry = StringTrimLeft($new_entry, 2) endif endif if StringInStr($path_entry, "/") and not StringInStr($path_entry, "\") then $new_entry = StringReplace($new_entry, "\", "/") if $quoted then $new_entry = '"' & $new_entry & '"' return SetExtended(1, $new_entry) endfunc func ChangeArrayToLogString($changes_array, $Undo=false) local $logstr, $ok = "OK" if $Undo then $ok = "Undo" for $i = 1 to $changes_array[0] if StringInStr($changes_array[$i], "|") then local $l_pair = StringSplit($changes_array[$i], "|", 2) local $l_path = GetParent($l_pair[0]) $logstr &= $ok & ": " & $l_path & "\" & BaseName($l_pair[0]) & " >> " & BaseName($l_pair[1]) & $lf endif next return $logstr endfunc func MatchFileName($string) if (not $search_for) or (not $string) then return local $test = false if $use_regexp = $ON then $test = StringRegExp($string, $search_for) else $test = (StringInStr($string, $search_for) > 0) endif return $test endfunc func Undo() if not IsArray($undos) then return DialogOpen($mzGUI) InfoTitle("UNDoing..", $info_time * 10000) local $done_files = 0 local $logundo = $undos for $i = $undos[0] to 1 step -1 $logundo[$undos[0] - $i + 1] = "" if $undos[$i] == "" then continueloop local $change = StringSplit($undos[$i], "|") if $change[0] = 2 then local $flag = 0 if $change[2] = $change[1] and not ($change[2] == $change[1]) then $flag = 1 local $moved = ItemMove($change[2], $change[1], $flag) if $moved then $done_files += 1 $logundo[$undos[0] - $i + 1] = $change[2] & "|" & $change[1] endif endif next if $done_files > 0 then UpdateRenameReferences($logundo) ToggleEnableUndo(false) local $title_msg = "" if $done_files > 0 then $title_msg = $done_files & " Names Reverted" else $title_msg = "Nothing Done!" endif if $log_file then local $log_str = @Hour & ":" & @Min & ":" & @Sec & ": >> Undo OPERATION << : " & $lf & $lf if $done_files > 0 then $log_str &= ChangeArrayToLogString($logundo, true) else $log_str &= "Nothing Done!" & $lf endif DoLog($log_str, $log_append) endif $undos = 0 DialogClose($mzGUI) InfoTitle($title_msg) endfunc func ToggleEnableUndo($switch_on=true) if $switch_on then TrayItemSetState($tray_undo, $TRAY_ENABLE) GUICtrlSetState($but_undo, $GUI_ENABLE) else TrayItemSetState($tray_undo, $TRAY_DISABLE) GUICtrlSetState($but_undo, $GUI_DISABLE) endif endfunc func DoPrefsGUI() local $last_event_mode = AutoItSetOption("GUIOnEventMode", 0) local $last_coord_mode = AutoItSetOption("GUICoordMode", 1) DialogOpen($mzGUI) local $p_width = 410 local $p_hight = 230 local $prefs_x = IniRead($ini_path, $my_name, "prefs_x", $x) local $prefs_y = IniRead($ini_path, $my_name, "prefs_y", $y) local $gui_prefs = GUICreate(" MangleeZee Preferences..", $p_width, $p_hight, $prefs_x, $prefs_y, Bitor($WS_CAPTION, $WS_SYSMENU), $WS_EX_TOPMOST, $mzGUI) GUISetIcon($me_app, 0, $gui_prefs) local $tmp_ignore_files = IniRead($ini_path, $my_name, "ignore_files", "desktop.ini,folder.jpg,.desktop,thumbs.db") local $tmp_checksum_extension = $checksum_extension local $sz_start = GUICtrlCreateGroup("Behaviour..", 5, 5, $p_width - 10, 70) local $chk_rename_hidden = GUICtrlCreateCheckbox("Hidden files:", 15, 23, 88, 20, $BS_RIGHTBUTTON) GUICtrlSetState(-1, $rename_hidden) local $chk_rename_checksum_entries = GUICtrlCreateCheckbox("checksum files:", 117, 23, 92, 20, $BS_RIGHTBUTTON) GUICtrlSetState(-1, $rename_checksum_entries) local $lab_checksum_extension = GUICtrlCreateLabel("Extension(s):", 215, 26, 68, 17) local $inp_checksum_extension = GUICtrlCreateInput($tmp_checksum_extension, 286, 23, $p_width - 301, 20) local $lab_ignore_files = GUICtrlCreateLabel("Ignored files: ", 15, 48) local $inp_ignore_files = GUICtrlCreateInput($tmp_ignore_files, 85, 45, $p_width - 100, 20) GUICtrlCreateGroup("Interface..", 5, 75, $p_width - 10, 72) local $chk_show_tips = GUICtrlCreateCheckbox("Show tooltips:", 15, 93, 88, default, $BS_RIGHTBUTTON) GUICtrlSetState(-1, $show_tips) local $chk_taskbar_entry = GUICtrlCreateCheckbox("Taskbar entry:", 135, 93, 92, default, $BS_RIGHTBUTTON) GUICtrlSetState(-1, $taskbar_entry) local $chk_fade_in = GUICtrlCreateCheckbox("Fade-in:", 245, 93, 55, default, $BS_RIGHTBUTTON) GUICtrlSetState(-1, $fade_in) GUICtrlCreateLabel("Speed: ", 315, 96) local $inp_fade_speed = GUICtrlCreateInput($fade_speed, 355, 93, 37, 20) local $lab_info_time = GUICtrlCreateLabel("Info time: ", 15, 119, 50) local $slide_info_time = GUICtrlCreateSlider(65, 116, 70, 22, $TBS_NOTICKS) GUICtrlSetLimit(-1, 10, 1) GUICtrlSetData(-1, $info_time) local $chk_hover_to_show = GUICtrlCreateCheckbox("Hover to show:", 135, 116, 92, default, $BS_RIGHTBUTTON) GUICtrlSetState(-1, $hover_to_show) local $lab_hov_sens = GUICtrlCreateLabel("Sensitivity: ", 245, 119) local $slide_hov_sens = GUICtrlCreateSlider(295, 116, 100, 22, $TBS_NOTICKS) GUICtrlSetLimit(-1, 10, 1) GUICtrlSetData(-1, $hover_sensitivity) GUICtrlCreateGroup("Logging..", 5, 147, $p_width - 10, 50) local $lab_log_file = GUICtrlCreateLabel("Log file: ", 15, 169) local $disp_log_file = "" if $log_file then $disp_log_file = Tokenize($log_file) local $inp_log_file = GUICtrlCreateInput($disp_log_file, 60, 166, $p_width - 145, 20) local $chk_log_append = GUICtrlCreateCheckbox("Append:", $p_width - 75, 166, 60, default, $BS_RIGHTBUTTON) GUICtrlSetState(-1, $log_append) local $gui_prefs_no = GUICtrlCreateButton("Cancel", $p_width - 140, $p_hight - 25, 65, 22) local $gui_prefs_ok = GUICtrlCreateButton("Save", $p_width - 70, $p_hight - 25, 65, 22) if $show_tips = $ON then GUICtrlSetTip($chk_rename_hidden, " I can easily rename hidden files. " & @LF & " But if you can't see them, it might be confusing. You decide. ") GUICtrlSetTip($chk_rename_checksum_entries, " Also rename matching file and folder paths inside related reference files. " & @LF & _ " This updates checksum files using the extensions listed here, plus playlists (.m3u, .m3u8 and .pls). " & @LF & _ " Piped checksum files such as file.md5 and file.jpg.md5 are renamed with their file. " & @LF & _ " Disable this to leave checksum contents and sidecar names unchanged. ") local $hash_files_str = " A comma-delimited list of checksum file extensions, without leading dots. " & @LF & " For example: hash,md5,sha2 " GUICtrlSetTip($lab_checksum_extension, $hash_files_str) GUICtrlSetTip($inp_checksum_extension, $hash_files_str) GUICtrlSetTip($lab_ignore_files, " These files will NEVER be renamed. Ever.") GUICtrlSetTip($inp_ignore_files, " This is simply a comma-delimited list of file names. " & @LF & " e.g. desktop.ini,folder.jpg,.desktop,thumbs.db") GUICtrlSetTip($chk_show_tips, " Show handy ToolTip help when your mouse hovers over a control?" & @LF & " Note: ToolTip changes take effect fully after you restart me. ") GUICtrlSetTip($chk_taskbar_entry, " Show me in your Windows Taksbar? It's cute to hide me, but note: " & @LF & _ " when disabled (unchecked) you won't see me during Alt-Tab operations;" & @LF & _ " nor will I respond to a Windows Minimize-All command (Win+M). Your call. " & @LF & _ " Note: You need to restart me to see this change") GUICtrlSetTip($chk_fade_in, " I like to fade-in gently at startup - easy on the eyes. You can disable this.") GUICtrlSetTip($inp_fade_speed, " You can adjust the speed at which I fade-in, too. (1-100, 100 being instant)") GUICtrlSetTip($lab_info_time, SlideTipInfoTime(GUICtrlRead($slide_info_time))) GUICtrlSetTip($slide_info_time, SlideTipInfoTime(GUICtrlRead($slide_info_time))) GUICtrlSetTip($chk_hover_to_show, " if my main window is hidden behind other windows," & @LF & _ " you can hover your mouse over the tray icon to bring me to the front. " & @LF & _ " Note: Clicking my tray icon will ALWAYS toggle my main window, regardless. ") GUICtrlSetTip($lab_hov_sens, SlideTipHoverSensitivity($hover_sensitivity)) GUICtrlSetTip($slide_hov_sens, SlideTipHoverSensitivity($hover_sensitivity)) GUICtrlSetTip($lab_log_file, " Enter the full path to your preferred log file.. ") GUICtrlSetTip($inp_log_file, " Note: You can use @tokens in this path. See my web page for details.") GUICtrlSetTip($chk_log_append, " Check this to have new log outpout added onto the end of the old log" & @LF & " Otherwise you get a new log with each launch. ") endif for $szs = $sz_start to $gui_prefs_ok GUICtrlSetResizing($szs, $GUI_DOCKALL) next GUICtrlSetState($gui_prefs_no, $GUI_FOCUS) GUISetState() if WinExists($mzGUI) then GUISetState(@Sw_Disable, $mzGUI) while 1 local $msg = GUIGetMsg() switch $msg case $GUI_EVENT_CLOSE, $gui_prefs_no GUIDelete($gui_prefs) exitloop case $GUI_EVENT_PRIMARYUP local $size_array = WinGetPos($gui_prefs) if IsArray($size_array) then if $size_array[0] < 0 then WinMove($gui_prefs, "", 0, default) if $size_array[0] > @DesktopWidth - $size_array[2] then WinMove($gui_prefs, "", @DesktopWidth - $size_array[2], default) if $size_array[1] < 0 then WinMove($gui_prefs, "", default, 0) if $size_array[1] > @DesktopHeight - $size_array[3] then WinMove($gui_prefs, "", default, @DesktopHeight - $size_array[3]) endif case $chk_hover_to_show if GUICtrlRead($chk_hover_to_show) = $OFF then GUICtrlSetState($slide_hov_sens, $GUI_DISABLE) else GUICtrlSetState($slide_hov_sens, $GUI_ENABLE) endif case $slide_hov_sens if $show_tips = $ON then GUICtrlSetTip($slide_hov_sens, SlideTipHoverSensitivity(GUICtrlRead($slide_hov_sens))) case $slide_info_time if $show_tips = $ON then GUICtrlSetTip($slide_info_time, SlideTipInfoTime(GUICtrlRead($slide_info_time))) case $gui_prefs_ok SavePrefsXYPrefs() local $i = GUICtrlRead($chk_rename_hidden) if $rename_hidden <> $i then $rename_hidden = $i IniWriteCheckBoxValue($ini_path, $my_name, "rename_hidden", $rename_hidden) endif $i = GUICtrlRead($chk_rename_checksum_entries) if $rename_checksum_entries <> $i then $rename_checksum_entries = $i IniWriteCheckBoxValue($ini_path, $my_name, "rename_checksum_entries", $rename_checksum_entries) endif $i = NormalizeExtensionList(GUICtrlRead($inp_checksum_extension)) if not $i or StringLower($i) = "unset" then $i = "hash" $checksum_extension = $i if $tmp_checksum_extension <> $checksum_extension then IniWrite($ini_path, $my_name, "checksum_extension", $checksum_extension) endif $i = GUICtrlRead($inp_ignore_files) if $tmp_ignore_files <> $i then $ignore_files = StringSplit($i, ",") IniWrite($ini_path, $my_name, "ignore_files", $i) endif $i = GUICtrlRead($chk_show_tips) if $show_tips <> $i then $show_tips = $i IniWriteCheckBoxValue($ini_path, $my_name, "show_tips", $show_tips) endif $i = GUICtrlRead($chk_taskbar_entry) if $taskbar_entry <> $i then $taskbar_entry = $i IniWriteCheckBoxValue($ini_path, $my_name, "taskbar_entry", $taskbar_entry) endif $i = GUICtrlRead($chk_fade_in) if $fade_in <> $i then $fade_in = $i IniWriteCheckBoxValue($ini_path, $my_name, "fade_in", $fade_in) endif $i = GUICtrlRead($inp_fade_speed) if $fade_speed <> $i then if $i <= 100 and $i > 0 then $fade_speed = $i IniWrite($ini_path, $my_name, "fade_speed", $fade_speed) endif endif $i = GUICtrlRead($chk_hover_to_show) if $hover_to_show <> $i then $hover_to_show = $i IniWriteCheckBoxValue($ini_path, $my_name, "hover_to_show", $hover_to_show) endif $i = GUICtrlRead($slide_hov_sens) if $hover_sensitivity <> $i then $hover_sensitivity = Int($i) IniWrite($ini_path, $my_name, "hover_sensitivity", $hover_sensitivity) endif $i = GUICtrlRead($slide_info_time) if $info_time <> $i then $info_time = $i IniWrite($ini_path, $my_name, "info_time", $info_time) endif $i = Detokenize(GUICtrlRead($inp_log_file)) if TestLogFileWritable($i) then $log_file = $i IniWrite($ini_path, $my_name, "log_file", Tokenize($log_file)) else $log_file = false IniWrite($ini_path, $my_name, "log_file", "") endif $i = GUICtrlRead($chk_log_append) if $log_append <> $i then $log_append = $i IniWriteCheckBoxValue($ini_path, $my_name, "log_append", $log_append) endif GUIDelete($gui_prefs) exitloop endswitch Sleep(10) wend AutoItSetOption("GUICoordMode", $last_coord_mode) AutoItSetOption("GUIOnEventMode", $last_event_mode) DialogClose($mzGUI) endfunc func SavePrefsXYPrefs() local $size_array = WinGetPos(" MangleeZee Preferences..") if not IsArray($size_array) then return 0 if $size_array[0] >= 0 and $size_array[0] < (@DesktopWidth - 25) then IniWrite($ini_path, $my_name, "prefs_x", $size_array[0]) if $size_array[1] >= 0 and $size_array[1] < (@DesktopHeight - 25) then IniWrite($ini_path, $my_name, "prefs_y", $size_array[1]) endfunc func SlideTipHoverSensitivity($cur_sense) return " Slide left to reduce sensitivity, right to increase sensitivity.. Currently: " & $cur_sense & @LF & _ " At minimum you will have to hover the mouse over the tray icon for a good second. " & @LF & _ " At maximum, I pop to the front almost instantaneously. " endfunc func SlideTipInfoTime($cur_time) local $plu = "" if $cur_time > 1 then $plu = "s" return " After each task, I flash information in my Title Bar. " & @LF & _ " This slider affects how long the Title Bar information is " & @LF & _ " displayed, from 1 to 10 seconds. Currently " & $cur_time & " second" & $plu & "." & @LF & _ " Note: Error messages always display for twice this amount of time. " endfunc func SaveSettings() SaveRepLimit() SaveUseRegExp() SaveNameMatch() SetComboToCurrent($combo_source_folder, "source_folder") SetComboToCurrent($combo_file_mask, "file_mask") SetComboToCurrent($combo_search_for, "search_for") SetComboToCurrent($combo_replace_with, "replace_with") SetComboToCurrent($combo_extension, "extension") endfunc func SaveRepLimit() local $i = Int(GUICtrlRead($inp_rep_limit)) if $rep_limit <> $i then $rep_limit = $i IniWrite($ini_path, $my_name, "rep_limit", $rep_limit) endif endfunc func SaveUseRegExp() local $i = GUICtrlRead($chk_use_regexp) if $use_regexp <> $i then $use_regexp = $i IniWriteCheckBoxValue($ini_path, $my_name, "use_regexp", $use_regexp) endif endfunc func SaveNameMatch() local $i = GUICtrlRead($chk_match_name) if $match_name <> $i then $match_name = $i IniWriteCheckBoxValue($ini_path, $my_name, "match_name", $match_name) endif endfunc func SetRecursive() $recursive = GUICtrlRead($chk_recursive) if $recursive = $GUI_CHECKED and IniReadCheckBoxValue($ini_path, "dialogs", "recursive warning", $GUI_UNCHECKED) = $GUI_UNCHECKED then MsgBox(48, "BE CAREFUL OUT THERE!", "Recursive operation is now enabled! " & @LF & @LF & _ "With this option enabled, MangleeZee will rename ALL specified files within the chosen folder" & @LF & _ "as well as inside ALL interior folders, as well as any folders inside them, and so on..." & @LF & @LF & _ "BE CAREFUL!" & @LF & @LF & "This is a one-time notice!", 600) IniWriteCheckBoxValue($ini_path, "dialogs", "recursive warning", "yes") endif IniWriteCheckBoxValue($ini_path, $my_name, "recursive", $recursive) endfunc func SetDoFolders() $do_folders = GUICtrlRead($chk_do_folders) IniWriteCheckBoxValue($ini_path, $my_name, "do_folders", $do_folders) SetFolderOnlyChkState() endfunc func SetOnlyFolders() $only_folders = GUICtrlRead($chk_only_folders) IniWriteCheckBoxValue($ini_path, $my_name, "only_folders", $only_folders) endfunc func SetFolderOnlyChkState() if $do_folders = $ON then GUICtrlSetState($chk_only_folders, $GUI_ENABLE) else GUICtrlSetState($chk_only_folders, $GUI_DISABLE) endif GUICtrlSetState($chk_only_folders, $only_folders) endfunc func SaveXYPrefs() if not CheckSize() then return 0 local $size_array = WinGetPos($mzGUI) if not IsArray($size_array) then return 0 if $x <> $size_array[0] and $size_array[0] >= 0 and $size_array[0] < (@DesktopWidth - 25) then IniWrite($ini_path, $my_name, "x", $size_array[0]) endif if $y <> $size_array[1] and $size_array[1] >= 0 and $size_array[1] < (@DesktopHeight - 25) then IniWrite($ini_path, $my_name, "y", $size_array[1]) endif $size_array = WinGetClientSize($mzGUI) if not IsArray($size_array) then return 0 if $size_array[0] <> $width and $size_array[0] >= $min_width then IniWrite($ini_path, $my_name, "width", $size_array[0]) if $size_array[1] <> $height and $size_array[1] >= $min_height then IniWrite($ini_path, $my_name, "height", $size_array[1]) endfunc func InfoTitle($info, $time="") if not $time then $time = $info_time AdlibUnRegister("ResetTitle") WinSetTitle($mzGUI, "", $my_name & " " & $info) AdlibRegister("ResetTitle", $time * 1000) endfunc func ResetTitle() WinSetTitle($mzGUI, "", $my_name) AdlibUnRegister("ResetTitle") endfunc func ViewLogFile() local $u_editor = IniRead($ini_path, $my_name, "editor", "notepad.exe") Run($u_editor & " " & $log_file) endfunc func AddToExplorerContext() $explorer_context = IniReadCheckBoxValue($ini_path, $my_name, "explorer_context", $ON) if $explorer_context = $OFF then $explorer_context = $ON else $explorer_context = $OFF endif local $context_action = "removed" if $explorer_context = $ON then $context_action = "installed" SetExplorerDirectoryContextMenu($my_name, $explorer_context, $my_name & "..", "", $me_app, $me_app & ",0") if @Error then TrayItemSetState($tray_explorer_context, $TRAY_DISABLE) MsgBox(BitOR($MB_OK, $MB_ICONERROR), "Explorer Context Menu", _ "The Explorer context commands could not be " & $context_action & ".") return endif TrayItemSetState($tray_explorer_context, $explorer_context) IniWriteCheckBoxValue($ini_path, $my_name, "explorer_context", $explorer_context) MsgBox(BitOR($MB_OK, $MB_ICONINFORMATION), "Explorer Context Menu", _ $my_name & " was successfully " & $context_action & ".") endfunc func WindowToFront() if not $visible then return if $hover_to_show = $GUI_UNCHECKED then return if $timer_stamp = 0 or _Timer_Diff($timer_stamp) > 1000 then $timer_stamp = _Timer_Init() endif local $diff = _Timer_Diff($timer_stamp) if $diff > ((11 - $hover_sensitivity) * 100) then $timer_stamp = 0 WinSetOnTop($mzGUI, "", 1) WinSetOnTop($mzGUI, "", 0) Sleep(100) WinActivate($mzGUI) RepaintGUI($mzGUI) endif endfunc func RepaintGUI($hwnd, $trect=0, $hregion=0, $iflags=5) local $prect, $aresult if $trect <> 0 then $prect = DllStructGetPtr($trect) $aresult = DllCall("User32.dll", "int", "RedrawWindow", "hwnd", $hwnd, "ptr", $prect, "int", $hregion, "int", $iflags) if IsArray($aresult) then return ($aresult[0] <> 0) endfunc func SetAlwaysOnTop() if $always_on_top = $ON then WinSetOnTop($mzGUI, "", 1) else WinSetOnTop($mzGUI, "", 0) endif endfunc func ToggleAlwaysOnTop() if $always_on_top = $OFF then $always_on_top = $ON else $always_on_top = $OFF endif SetAlwaysOnTop() TrayItemSetState($tray_always_on_top, $always_on_top) IniWriteCheckBoxValue($ini_path, $my_name, "always_on_top", $always_on_top) endfunc func TrayToggleWindow() ToggleWindow() endfunc func ToggleWindow() local $winstate = WinGetState($mzGUI) if BitAND($winstate, 2) then UnsetHotKeys() GUISetState(@Sw_Hide, $mzGUI) $visible = false ReduceMemory() else GUISetState(@Sw_Show, $mzGUI) $visible = true SetHotKeys() endif endfunc func Tokenize($string) $string = StringReplace($string, "/", "\") $string = StringReplace($string, "\\", "\") $string = TokenizePath($string) if StringRight($string, 1) = "\" then $string = StringTrimRight($string, 1) return $string endfunc func Detokenize($string) $string = StringReplace($string, "/", "\") $string = StringReplace($string, "\\", "\") $string = DetokenizePath($string) if StringRight($string, 1) = "\" then $string = StringTrimRight($string, 1) return RemoveTokens($string) endfunc func TokenizePath($string) select case StringInStr($string, $data_parent) == 1 if StringInStr(StringReplace($string, $data_parent, "@userdir", 1), ".") <> 9 then $string = StringReplace($string, $data_parent, "@userdir", 1) else continuecase endif case StringInStr($string, @AppDataDir) == 1 $string = StringReplace($string, @AppDataDir, "@appdatadir", 1) case StringInStr($string, @AppDataCommonDir) == 1 $string = StringReplace($string, @AppDataCommonDir, "@appdatacommon", 1) case StringInStr($string, @DesktopDir) == 1 $string = StringReplace($string, @DesktopDir, "@desktop", 1) case StringInStr($string, @UserProfileDir) == 1 $string = StringReplace($string, @UserProfileDir, "@homedir", 1) case StringInStr($string, @MyDocumentsDir) == 1 $string = StringReplace($string, @MyDocumentsDir, "@mydocs", 1) case StringInStr($string, @ProgramFilesDir) == 1 $string = StringReplace($string, @ProgramFilesDir, "@programsdir", 1) case StringInStr($string, @WindowsDir) == 1 $string = StringReplace($string, @WindowsDir, "@windowsdir", 1) endselect return $string endfunc func DetokenizePath($string) select case StringInStr($string, "@userdir") == 1 $string = StringReplace($string, "@userdir", $data_parent, 1) case StringInStr($string, "@appdatacommon") == 1 $string = StringReplace($string, "@appdatacommon", @AppDataCommonDir, 1) case StringInStr($string, "@appdatadir") == 1 $string = StringReplace($string, "@appdatadir", @AppDataDir, 1) case StringInStr($string, "@desktop") == 1 $string = StringReplace($string, "@desktop", @DesktopDir, 1) case StringInStr($string, "@homedir") == 1 $string = StringReplace($string, "@homedir", @UserProfileDir, 1) case StringInStr($string, "@mydocs") == 1 $string = StringReplace($string, "@mydocs", @MyDocumentsDir, 1) case StringInStr($string, "@programsdir") == 1 $string = StringReplace($string, "@programsdir", @ProgramFilesDir, 1) case StringInStr($string, "@windowsdir") == 1 $string = StringReplace($string, "@windowsdir", @WindowsDir, 1) endselect return $string endfunc func RemoveTokens($string) $string = StringReplace($string, "@appdatacommon", "") $string = StringReplace($string, "@appdatacommon\", "") $string = StringReplace($string, "@appdatadir", "") $string = StringReplace($string, "@appdatadir\", "") $string = StringReplace($string, "@desktop", "") $string = StringReplace($string, "@desktop\", "") $string = StringReplace($string, "@homedir", "") $string = StringReplace($string, "@homedir\", "") $string = StringReplace($string, "@mydocs", "") $string = StringReplace($string, "@mydocs\", "") $string = StringReplace($string, "@programsdir", "") $string = StringReplace($string, "@programsdir\", "") $string = StringReplace($string, "@userdir", "") $string = StringReplace($string, "@userdir\", "") $string = StringReplace($string, "@windowsdir", "") $string = StringReplace($string, "@windowsdir\", "") return $string endfunc func DetokenizeReplaceString($string, $file) if StringInStr($string, "@exif{") then $string = ReplaceExifTokens($string, $file) $string = StringReplace($string, "@sec", @Sec) $string = StringReplace($string, "@min", @Min) $string = StringReplace($string, "@hour", @Hour) $string = StringReplace($string, "@wday", @WDay) $string = StringReplace($string, "@mday", @MDay) $string = StringReplace($string, "@yday", @YDay) $string = StringReplace($string, "@mon", @Mon) $string = StringReplace($string, "@year", @Year) $string = StringReplace($string, "@time", @Year & "-" & @Mon & "-" & @MDay & " " & @Hour & "-" & @Min & "-" & @Sec) if StringInStr($string, "@fileparent") then $string = StringReplace($string, "@fileparent", BaseName(GetParent($file))) endif if StringInStr($string, "@filesize") then $string = StringReplace($string, "@filesizeg", Stringformat("%02.02f", FileGetSize($file) / 1073741824)) $string = StringReplace($string, "@filesizem", Stringformat("%02.02f", FileGetSize($file) / 1048576)) $string = StringReplace($string, "@filesizek", Stringformat("%02.02f", FileGetSize($file) / 1024)) $string = StringReplace($string, "@filesize", FileGetSize($file)) endif if StringInStr($string, "@filedatec") or StringInStr($string, "@filetimec") then local $filetime = FileGetTime($file, 1) elseif StringInStr($string, "@filedate") or StringInStr($string, "@filetime") then $filetime = FileGetTime($file) endif if StringInStr($string, "@filedatec") then $string = StringReplace($string, "@filedatec", $filetime[0] & "-" & $filetime[1] & "-" & $filetime[2]) endif if StringInStr($string, "@filetimec") then $string = StringReplace($string, "@filetimec", $filetime[3] & "." & $filetime[4]) endif if StringInStr($string, "@filedate") then $string = StringReplace($string, "@filedate", $filetime[0] & "-" & $filetime[1] & "-" & $filetime[2]) endif if StringInStr($string, "@filetime") then $string = StringReplace($string, "@filetime", $filetime[3] & "." & $filetime[4]) endif if StringInStr($string, "@count") then local $disp_count = Stringformat("%0" & $count_ints & "d", $count) if $count <= $count_end then $string = StringReplace($string, "@count", $disp_count) else $string = StringReplace($string, "@count", "") endif endif if StringInStr($string, "@format") then $string = DoStringFormat($string) endif return $string endfunc func ReplaceExifTokens($string, $file) _GDIPlus_Startup() local $image = _GDIPlus_ImageLoadFromFile($file) if not $image then _GDIPlus_Shutdown() return StringRegExpReplace($string, "(?i)@exif\{[^{}]+\}", "") endif local $properties = _GDIPlus_ImageGetPropertyIdList($image) local $matches = StringRegExp($string, "(?i)@exif\{([^{}]+)\}", 3) for $match in $matches local $token = "@exif{" & $match & "}" local $property_id = GetExifPropertyId(StringStripWS($match, 3), $properties) local $value = "" if $property_id >= 0 then $value = GetExifPropertyValue($image, $property_id) $string = StringReplace($string, $token, $value) next _GDIPlus_ImageDispose($image) _GDIPlus_Shutdown() return $string endfunc func GetExifPropertyId($tag, $properties) if StringRegExp($tag, "(?i)^0x[0-9a-f]{1,4}$") then return Dec(StringTrimLeft($tag, 2)) local $property_id = GetExifNamedPropertyId($tag) if $property_id >= 0 then return $property_id if not IsArray($properties) then return -1 for $i = 1 to $properties[0][0] if StringLower($properties[$i][1]) = StringLower($tag) then return $properties[$i][0] next return -1 endfunc func GetExifNamedPropertyId($tag) switch StringLower($tag) case "imagewidth" return 0x0100 case "imageheight" return 0x0101 case "imagedescription", "description" return 0x010E case "make" return 0x010F case "model" return 0x0110 case "orientation" return 0x0112 case "software" return 0x0131 case "datetime" return 0x0132 case "artist" return 0x013B case "copyright" return 0x8298 case "exposuretime" return 0x829A case "fnumber" return 0x829D case "exposureprogram" return 0x8822 case "iso", "isospeed", "isospeedratings" return 0x8827 case "datetimeoriginal" return 0x9003 case "datetimedigitized" return 0x9004 case "shutterspeedvalue" return 0x9201 case "aperturevalue" return 0x9202 case "brightnessvalue" return 0x9203 case "exposurebiasvalue", "exposurebias" return 0x9204 case "maxaperturevalue" return 0x9205 case "subjectdistance" return 0x9206 case "meteringmode" return 0x9207 case "lightsource" return 0x9208 case "flash" return 0x9209 case "focallength" return 0x920A case "usercomment" return 0x9286 case "colorspace" return 0xA001 case "pixelxdimension", "width" return 0xA002 case "pixelydimension", "height" return 0xA003 case "flashenergy" return 0xA20B case "exposureindex" return 0xA215 case "sensingmethod" return 0xA217 case "cameraownername" return 0xA430 case "bodyserialnumber" return 0xA431 case "lensspecification" return 0xA432 case "lensmake" return 0xA433 case "lensmodel" return 0xA434 case "lensserialnumber" return 0xA435 endswitch return -1 endfunc func GetExifPropertyValue($image, $property_id) local $values = _GDIPlus_ImageGetPropertyItem($image, $property_id) if not IsArray($values) then return "" local $value = "" for $i = 1 to $values[0] if $i > 1 then $value &= "," $value &= String($values[$i]) next $value = StringRegExpReplace($value, "[<>:""/\\|?*\x00-\x1F]", "-") return StringRegExpReplace($value, "[ .]+$", "") endfunc func DoStringFormat($string) local $fmt_len = 7 while StringInStr($string, "@format") local $new_str = "" local $fmt_pos = StringInStr($string, "@format") ; local $start_pos = StringMid($string, $fmt_pos + $fmt_len, 1) local $end_pos = StringInStr(StringMid($string, $fmt_pos + $fmt_len + 1), "}") local $format_str = StringMid($string, $fmt_pos + $fmt_len + 1, $end_pos - 1) if StringInStr($format_str, ",") then local $format_arr = StringSplit($format_str, ",", 2) $new_str &= Stringformat($format_arr[0], $format_arr[1]) endif $string = StringRegExpReplace($string, "(?i)@format(\{[^}]+\})?", $new_str, 1) wend return $string endfunc func CheckCountParams($string, $token) $count = 1 $count_ints = 1 $count_end = 1.7e+308 local $cnt_pos = StringInStr($string, $token) local $toklen = StringLen($token) if $cnt_pos then if StringMid($string, $cnt_pos + $toklen, 1) = "{" then $count_ints = Number(StringMid($string, $cnt_pos + $toklen + 1, 1)) if StringMid($string, $cnt_pos + $toklen + 2, 1) <> "}" then local $end_pos = StringInStr(StringMid($string, $cnt_pos + 7), "}") local $cnt_vars = StringMid($string, $cnt_pos + 7, $end_pos - 1) local $cnt_var_arr = StringSplit($cnt_vars, ",") if $cnt_var_arr[0] > 1 then $count = $cnt_var_arr[2] if $cnt_var_arr[0] > 2 then $count_end = $cnt_var_arr[3] endif endif endif $replace_with = StringRegExpReplace($replace_with, "(?i)@count\{[^}]+\}", "@count") endif endif endfunc func Proper($s_string) local $ix = 0 local $capnext = 1 local $s_nstr = "" local $s_curchar for $ix = 1 to StringLen($s_string) $s_curchar = StringMid($s_string, $ix, 1) ;local $prev_char = StringMid($s_string, $ix - 1, 1) select case $capnext = 1 if StringRegExp($s_curchar, "[a-zA-ZÀ-ÿšœžŸ]") then $s_curchar = StringUpper($s_curchar) $capnext = 0 endif case not StringRegExp($s_curchar, "[a-zA-ZÀ-ÿšœžŸ']") $capnext = 1 case else $s_curchar = StringLower($s_curchar) endselect $s_nstr &= $s_curchar next return $s_nstr endfunc func ResizeCheckSize() CheckSize() endfunc func PrimaryUpCheckSize() CheckSize() endfunc func CheckSize($save=true) local $size_array = WinGetPos($mzGUI) if not $visible then return if not IsArray($size_array) then return 0 if $size_array[2] < $min_width + $width_magic then WinMove($mzGUI, "", default, default, $min_width + $width_magic) if $size_array[3] < $min_height + $height_magic + $GROUP_BOTTOM_MARGIN then WinMove($mzGUI, "", default, default, default, $min_height + $height_magic + $GROUP_BOTTOM_MARGIN) if $max_height and $size_array[3] > $max_height + $height_magic then WinMove($mzGUI, "", default, default, default, $max_height + $height_magic) Sleep(25) $size_array = WinGetPos($mzGUI) if not IsArray($size_array) then return 0 if $size_array[0] > @DesktopWidth - $size_array[2] then WinMove($mzGUI, "", @DesktopWidth - $size_array[2], default, default) if $size_array[1] > @DesktopHeight - $size_array[3] then WinMove($mzGUI, "", default, @DesktopHeight - $size_array[3], default) Sleep(25) $size_array = WinGetPos($mzGUI) if not IsArray($size_array) then return 0 if $size_array[0] < 0 then WinMove($mzGUI, "", 0, default) if $save then IniWrite($ini_path, $my_name, "x", 0) endif if $size_array[0] > @DesktopWidth - $size_array[2] then WinMove($mzGUI, "", @DesktopWidth - $size_array[2], default) if $save then IniWrite($ini_path, $my_name, "x", @DesktopWidth - $size_array[2]) endif if $size_array[1] < 0 then WinMove($mzGUI, "", default, 0) if $save then IniWrite($ini_path, $my_name, "y", 0) endif if $size_array[1] > @DesktopHeight - $size_array[3] then WinMove($mzGUI, "", default, @DesktopHeight - $size_array[3]) if $save then IniWrite($ini_path, $my_name, "y", @DesktopHeight - $size_array[3]) endif return true endfunc func DialogOpen($my_gui) GUISetState(@Sw_Disable, $my_gui) TraySetState(2) UnsetHotKeys() endfunc func DialogClose($my_gui) TraySetState(1) GUISetState(@Sw_Enable, $my_gui) WinActivate($my_gui) GUIswitch($my_gui) SetHotKeys() endfunc func SetHotKeys() $hot_quit_label = RegisterHotKey("{Esc}", "Esc", "", "", "HKDoQuit", $hot_quit_key) $hot_undo_label = RegisterHotKey("^!z", "Ctrl-Alt-Z", "^!u", "Ctrl-Alt-U", "HKUndo", $hot_undo_key) $hot_prefs_label = RegisterHotKey("{F6}", "F6", "^!{F6}", "Ctrl-Alt-F6", "HKDoPrefsGUI", $hot_prefs_key) $hot_ini_label = RegisterHotKey("{F7}", "F7", "^!{F7}", "Ctrl-Alt-F7", "HKEditINIFile", $hot_ini_key) $hot_log_label = RegisterHotKey("{F8}", "F8", "^!{F8}", "Ctrl-Alt-F8", "HKViewLogFile", $hot_log_key) UpdateHotKeyMenu() endfunc func UnsetHotKeys() if $hot_quit_key then HotKeySet($hot_quit_key) if $hot_undo_key then HotKeySet($hot_undo_key) if $hot_prefs_key then HotKeySet($hot_prefs_key) if $hot_ini_key then HotKeySet($hot_ini_key) if $hot_log_key then HotKeySet($hot_log_key) ResetCtrlKey() endfunc ; Register the first free hotkey from a primary and spare pair for one action. ; Data in: $primary and $backup contain HotKeySet key strings, $primary_label ; and $backup_label contain the matching menu text, $handler names the ; function to call, $active_key receives the registered key. Reads no other ; globals. Data out: the label of the registered key, or "" when both keys ; are already taken. Called for every hotkey by SetHotKeys. func RegisterHotKey($primary, $primary_label, $backup, $backup_label, $handler, byref $active_key) #Au3Stripper_Ignore_Funcs=$handler $active_key = "" if HotKeySet($primary, $handler) then $active_key = $primary return $primary_label endif if $backup and HotKeySet($backup, $handler) then $active_key = $backup return $backup_label endif return "" endfunc ; Build the tray text for one action, naming the live hotkey when one exists. ; Data in: $base names the action, $label names the registered hotkey or is ; "". Reads no globals. Data out: $base plus the hotkey, or $base plus a ; note that no hotkey is available. Called by UpdateHotKeyMenu. func HotKeyMenuText($base, $label) if not $label then return $base & " (HotKey Unavailable)" return $base & @Tab & $label endfunc ; Refresh tray text and the Undo tip to name the live hotkeys, or flag dead ones. ; Data in: none. Reads the $hot key and label globals plus the tray and ; button handles. Data out: none. Called by SetHotKeys after registration. func UpdateHotKeyMenu() if $tray_undo then TrayItemSetText($tray_undo, HotKeyMenuText("Undo last operation", $hot_undo_label)) if $tray_prefs then TrayItemSetText($tray_prefs, HotKeyMenuText("Preferences", $hot_prefs_label)) if $tray_editini then TrayItemSetText($tray_editini, HotKeyMenuText("Edit MangleeZee.ini", $hot_ini_label)) if $tray_viewlog then TrayItemSetText($tray_viewlog, HotKeyMenuText("View Log File..", $hot_log_label)) if $tray_quit then if $hot_quit_label then TrayItemSetText($tray_quit, "Quit" & @Tab & "Alt-F4/Esc") else TrayItemSetText($tray_quit, "Quit" & @Tab & "Alt-F4 (HotKey Unavailable)") endif endif if $but_undo then local $undo_tip = $hot_undo_label if not $undo_tip then $undo_tip = "HotKey Unavailable" GUICtrlSetTip($but_undo, " Undo the last operation. *phew* (" & $undo_tip & ") ") endif endfunc func ResetCtrlKey() Send("{CTRLDOWN}") Send("{CTRLUP}") endfunc func HKDoPrefsGUI() if WinActive($mzGUI) then DoPrefsGUI() else HotKeySet($hot_prefs_key) Send($hot_prefs_key) HotKeySet($hot_prefs_key, "HKDoPrefsGUI") endif endfunc func HKEditINIFile() if WinActive($mzGUI) then EditIniFile() else HotKeySet($hot_ini_key) Send($hot_ini_key) HotKeySet($hot_ini_key, "HKEditINIFile") endif endfunc func HKViewLogFile() if WinActive($mzGUI) then ViewLogFile() else HotKeySet($hot_log_key) Send($hot_log_key) HotKeySet($hot_log_key, "HKViewLogFile") endif endfunc func HKDoQuit() if WinActive($mzGUI) then DoQuit(0) else HotKeySet($hot_quit_key) Send($hot_quit_key) HotKeySet($hot_quit_key, "HKDoQuit") endif endfunc func HKUndo() if WinActive($mzGUI) then Undo() else HotKeySet($hot_undo_key) Send($hot_undo_key) HotKeySet($hot_undo_key, "HKUndo") endif endfunc func TrayQuit() DoQuit(0) endfunc func MenuDoQuit() DoQuit(0) endfunc func DoQuit($x=0) SaveSettings() SaveXYPrefs() if $log_file then DoLog("out", $log_append) VersionCheckOnline($my_name, $versioncheck_url, $download_url, $ini_path, $my_name, $my_version, -1) GUIDelete($mzGUI) exit $x endfunc func EventDoAboutBox() DoAboutBox($mzGUI) endfunc func DoAboutBox($my_gui) local $a_x = -1 local $a_y = -1 local $a_shunt = 0 local $d_height = 105 local $d_width = 265 local $txt_l = 80 ; local $i_paused = false ; local $title_settled = false ; local $will_exit = false if WinVisible($my_gui) then local $n_size_array = WinGetPos($my_gui) if IsArray($n_size_array) then $a_x = $n_size_array[0] + ($n_size_array[2] / 2) - ($d_width / 2) $a_y = $n_size_array[1] + ($n_size_array[3] / 2) - ($d_height) endif AboutDialogOpen($my_gui) endif local $last_event_mode = AutoItSetOption("GUIOnEventMode", 0) local $last_coord_mode = AutoItSetOption("GUICoordMode", 1) $gui_about = GUICreate(" About " & $my_name & "..", $d_width, $d_height + $a_shunt, $a_x, $a_y, default, Bitor($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST)) GUISetBkColor(16777215) local $x1 = GUICtrlCreateLabel($my_name & " v" & $my_version & $MSG_LF & "from corz.org", $txt_l, 8) FileInstall("Resources\about.gif", @TempDir & "\", 1) local $pic if FileExists(@TempDir & "\about.gif") then $pic = GUICtrlCreatePic(@TempDir & "\about.gif", 6, 9, 64, 64) else $pic = GUICtrlCreateIcon($me_app, 0, 6, 9, 64, 64) endif local $x2 = GUICtrlCreateLabel("Do you want to visit the " & $my_name & $MSG_LF & "web page at this time?", $txt_l, $a_shunt + 40) local $gui_about_no = GUICtrlCreateButton("No, not right now", 10, $a_shunt + 80, 95, 22) GUICtrlSetTip(-1, " The other button is the one you want to click! ") local $gui_about_ok = GUICtrlCreateButton("Yes, let's do it!", $d_width - 104, $a_shunt + 80, 95, 22) GUICtrlSetTip(-1, " The link will open in your system default browser ") local $vbit = "x86" if @AutoItX64 = 1 then $vbit = "x64" local $lab_v = GUICtrlCreateLabel($vbit, $d_width - 19, 1, 18, 12) GUICtrlSetFont(-1, 8, 200, 0, "Lucida Console") GUISetState() local $count = 1 local $my_action while 1 $count += 1 if Mod($count, 25) = 0 then GUICtrlSetColor($lab_v, 4473924) endif if Mod($count, 50) = 0 then GUICtrlSetColor($lab_v, 0) endif local $msg = GUIGetMsg() Sleep(33) switch $msg case $GUI_EVENT_CLOSE, $gui_about_no exitloop case $gui_about_ok $my_action = "url" exitloop case $pic $my_action = "url" exitloop case $x1, $x2 VisitUrl($reg_url) case $lab_v $my_action = "sysi" exitloop endswitch wend GUIDelete($gui_about) AutoItSetOption("GUICoordMode", $last_coord_mode) AutoItSetOption("GUIOnEventMode", $last_event_mode) switch $my_action case "url" VisitUrl($my_url) case "sysi" SysInfoBox($my_name) endswitch if WinVisible($my_gui) then AboutDialogClose($my_gui) endfunc func AboutDialogOpen($my_gui) GUISetState(@Sw_Disable, $my_gui) TraySetState(2) endfunc func AboutDialogClose($my_gui) TraySetState(1) GUISetState(@Sw_Enable, $my_gui) WinActivate($my_gui) GUIswitch($my_gui) endfunc ; AutoIt Wrapper / Compiler directives.. ; #region ; For resources included with FileInstall() #pragma compile(Compression, 9) ; If you want your binary NOW, comment this out.. #AutoIt3Wrapper_Run_Au3Stripper=Y ; #Au3Stripper_Ignore_Funcs=HKDoQuit,HKUndo,HKDoPrefsGUI,HKEditINIFile,HKViewLogFile ; See the notes above debug() for what /rsln does. #Au3Stripper_Parameters=/StripOnly /rsln ; Like calling the wrapper with /debug, which we do anyway. This is handy, though .. #AutoIt3Wrapper_Run_Debug_Mode=Y #AutoIt3Wrapper_LogFile=%scriptdir%\wrapper.log #AutoIt3Wrapper_UseX64=Y #AutoIt3Wrapper_UseUpx=N #AutoIt3Wrapper_Run_AU3Check=Y #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 -v 1 #AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y #AutoIt3Wrapper_Run_Stop_OnError=Y ; Main program icon.. #AutoIt3Wrapper_Icon=.\Resources\Icons\MangleeZee.ico ; Free-Form Res Fields.. #AutoIt3Wrapper_Res_Field=Author|corz.org #AutoIt3Wrapper_Res_Field=Contact|windows@corz.org #AutoIt3Wrapper_Res_Field=Instructions|2do #AutoIt3Wrapper_Res_Field=Publisher|corz.org #AutoIt3Wrapper_Res_Field=Web Page|https://corz.org/windows/software/MangleeZee/ #AutoIt3Wrapper_Res_Field=Compiled|%date% %time% ; These now have their own fields.. #AutoIt3Wrapper_Res_ProductName=MangleeZee #AutoIt3Wrapper_Res_CompanyName=corz.org #AutoIt3Wrapper_Res_LegalCopyright=corz.org ; Application's resource info.. #AutoIt3Wrapper_Res_Comment=MangleeZee ; This is the one that shows up in Process Explorer.. #AutoIt3Wrapper_Res_Description=MangleeZee - A truly dangerous renaming utility for Windows.. #AutoIt3Wrapper_Res_LegalCopyright=corz.org #AutoIt3Wrapper_Res_ProductVersion=1 #AutoIt3Wrapper_Res_HiDpi=Y #AutoIt3Wrapper_Res_Field=Build|Public Release ; #AutoIt3Wrapper_Res_Field=Build|Beta Release ;#AutoIt3Wrapper_Res_Field=Build|debug ; Run pre- & post-compile tasks elevated (yes).. #AutoIt3Wrapper_Run_Before_Admin=Y #AutoIt3Wrapper_Run_After_Admin=Y ; Tasks to perform BEFORE compilation.. ; You might want to comment this out (kills any running instance of MangleeZee).. #AutoIt3Wrapper_Run_Before=taskkill /F /T /IM MangleeZee.exe ; But if you do, copying your new binary over (below) probably won't work. ; Tasks to perform AFTER compilation.. ; Backup this version of the script (dropped into a backup.zip, below). So I don't have to remember to.. #AutoIt3Wrapper_Run_After=copy /Y "%in%" "%scriptfile% - %fileversion%.au3" ; Handy to keep a backup of the stripped version, too.. #AutoIt3Wrapper_Run_After=move /Y .\%scriptfile%_stripped.au3 "%scriptfile% - %fileversion%_stripped.au3" ;::dev::.. ; Your copy of MangleeZee may be somewhere else.. ; Copy latest binaries to app folders (overwrites existing binary).. #AutoIt3Wrapper_Run_After=copy /Y /Y "%outx64%" "C:\Program Files\corz\MangleeZee\MangleeZee.exe" ; Move latest binaries, etc. to distro folder (out of the way of the source).. #AutoIt3Wrapper_Run_After=mkdir "..\MangleeZee" #AutoIt3Wrapper_Run_After=copy /Y /Y "%outx64%" "..\MangleeZee\MangleeZee.exe" #AutoIt3Wrapper_Run_After=mkdir "..\MangleeZee\Info" #AutoIt3Wrapper_Run_After=copy /Y "Resources\QuickStart.txt" "..\MangleeZee\QuickStart.txt" #AutoIt3Wrapper_Run_After=copy /Y "Resources\MangleeZee.ini" "..\MangleeZee\Info\MangleeZee.ini" #AutoIt3Wrapper_Run_After=move "%outx64%" "C:\Program Files\corz\MangleeZee\MangleeZee.exe" ; Backup this version of the source files to BackUp.zip.. #AutoIt3Wrapper_Run_After=7z.exe a -mx7 -tzip "..\BackUp\BackUp.zip" "%scriptfile% - %fileversion%.au3" #AutoIt3Wrapper_Run_After=7z.exe a -mx7 -tzip "..\BackUp\BackUp.zip" "%scriptfile% - %fileversion%_stripped.au3" ; RELEASE.. ; Delete old distros if hanging around. #AutoIt3Wrapper_Run_After=del /a "C:\Users\Dad\Documents\Dev\AutoIt\MangleeZee\MangleeZee.hash" #AutoIt3Wrapper_Run_After=del "C:\Users\Dad\Documents\Dev\AutoIt\MangleeZee\MangleeZee.zip" ; NOTE: The 7z and checksum program directories are in my %PATH% (System Properties >> Advanced >> Environment Variables). ; Create zip of distro directory.. #AutoIt3Wrapper_Run_After=7z.exe a -mx7 -tzip "..\MangleeZee.zip" "..\MangleeZee\" ; Hash the zip.. #AutoIt3Wrapper_Run_After=checksum.exe cq-t-h "..\MangleeZee.zip" ; Backup this version of the source files to BackUp.zip.. #AutoIt3Wrapper_Run_After=7z.exe a -mx7 -tzip "..\BackUp\BackUp.zip" ".\%scriptfile% - %fileversion%.au3" #AutoIt3Wrapper_Run_After=7z.exe a -mx7 -tzip "..\BackUp\BackUp.zip" ".\%scriptfile% - %fileversion%_stripped.au3" ; Finally, remove the (now-zipped) source files.. #AutoIt3Wrapper_Run_After=del /f /q "%scriptfile% - %fileversion%.au3" #AutoIt3Wrapper_Run_After=del /f /q "%scriptfile% - %fileversion%_stripped.au3" ; #AutoIt3Wrapper_Run_After=start "" "C:\Program Files\corz\MangleeZee\MangleeZee.exe" #endregion