;======================================================================================================== ;RENAME FILE(S) WITH THEIR OWN PROPERITIE'S VERSION OR PRODUCT NUMBER ;======================================================================================================== ;#cs #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=.\Icons\File Renaming Application.ico #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Res_Comment=Free for Personal and Commercial use. #AutoIt3Wrapper_Res_Description="Rename File Name with File Property Values" #AutoIt3Wrapper_Res_Fileversion=1.4.0.3 #AutoIt3Wrapper_Res_ProductVersion=1.4.0 #AutoIt3Wrapper_Res_Field=ProductName|Rename File With File Properties #AutoIt3Wrapper_Res_LegalCopyright=Free for Personal and Commercial Use #AutoIt3Wrapper_Res_Language=1033 #AutoIt3Wrapper_Res_Field=Written and maintained by|David James ;#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y ;#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 #AutoIt3Wrapper_Run_Tidy=y #Tidy_Parameters=/tc 4 /ri /reel /sf #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so /rm #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ;#ce Opt("MustDeclareVars", 1) Opt('TrayMenuMode', 1) #include If _Singleton(@ScriptName, 1) = 0 Then Exit #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include Global $hOFNGUI, $hAFVGUI, $t_FV, $t_RC, $iniFolder = @ScriptDir & "\Ini Files\config.ini", $aPrefix, $afile[0], $aRepChars, $sFile = @ScriptDir & "\Icons\File Renaming Application.ico" Global $DefPrefixSet = "[|N_v|p/] [|N_v|f/] [|N_fv|f/] [|N_pv|p/] [|N_pv|p_fv|f/] [|P_pv|p/] [|e_v|p/]" Global $DefReplChar = "[_] [-] [.] [ ]" ;to replace illegal characters is Resultant Base File Names before renaming file Global $aXChars = StringSplit('/\:*?"<>|', "") ; illegal characters not allowed in Window's file names _Load_Any_Parameters() ;append file version to selected file Func _Append_File_Version(ByRef $aFileArg) Local $b_Edit_Ini, $b_Folder, $b_TestSS, $b_PrevPfx, $b_NextPfx, $b_PrevFile, $b_NextFile, $b_ClearRBFN Local $b_Cancel, $i_Index, $b_RenameFile, $b_LoadSS, $x, $Ans, $b_ClearSSEdit, $b_SaveSSEntry, $b_DelSSEntry, $BadChar, $NH, $f $i_Index = 2 ;first file in array. index 1 is the file's directory ; Retrieve the File's Properties Values. Local $sFileName = $aFileArg[$i_Index] Local $sFileFullDir = $aFileArg[1] & "\" & $aFileArg[$i_Index] Local $sFileOrigFileName = StringStripWS(FileGetVersion($sFileFullDir, $FV_ORIGINALFILENAME), 3) Local $sFileIntName = StringStripWS(FileGetVersion($sFileFullDir, $FV_INTERNALNAME), 3) Local $sFileProductName = StringStripWS(FileGetVersion($sFileFullDir, $FV_PRODUCTNAME), 3) Local $sFileDescription = StringStripWS(FileGetVersion($sFileFullDir, $FV_FILEDESCRIPTION), 3) Local $sFileVersion = StringStripWS(FileGetVersion($sFileFullDir), 3) Local $sFileProdVersion = StringStripWS(FileGetVersion($sFileFullDir, $FV_PRODUCTVERSION), 3) Local $sFilePrivBuild = StringStripWS(FileGetVersion($sFileFullDir, $FV_PRIVATEBUILD), 3) Local $sFileSpecialBuild = StringStripWS(FileGetVersion($sFileFullDir, $FV_SPECIALBUILD), 3) Local $sFileCopyright = FileGetVersion($sFileFullDir, $FV_LEGALCOPYRIGHT) Local $sFileCompanyName = StringStripWS(FileGetVersion($sFileFullDir, $FV_COMPANYNAME), 3) Local $sFileLegTradeMrks = FileGetVersion($sFileFullDir, $FV_LEGALTRADEMARKS) Local $sFileComments = FileGetVersion($sFileFullDir, $FV_COMMENTS) Local $sFileSize = FileGetSize($sFileFullDir) Local $sFileGetCreateTime = FileGetTime($sFileFullDir, $FT_CREATED, 0) Local $sFileGetModTime = FileGetTime($sFileFullDir, $FT_MODIFIED, 0) Local $sFileGetAccessTime = FileGetTime($sFileFullDir, $FT_ACCESSED, 0) Local $sFileAttribute = FileGetAttrib($sFileFullDir) Local $sDefLangCodePage = StringStripWS(FileGetVersion($sFileFullDir, "DefaultLangCodepage"), 3) Local $e_sFileName, $e_sFileFolder, $e_sFileOrigFileName, $e_sFileIntName, $e_sFileProductName, $e_sFileDescription, $l_sFileVersion, $l_sFileProdVersion, $e_sResFN, $l_sResFNLabel Local $l_sFilePrivBuild, $l_sFileSpecialBuild, $e_sFileCopyright, $e_sFileCompanyName, $e_sFileLegTradeMrks, $e_sFileComments, $l_sFileSize, $l_sFileGetCreateTime Local $l_sFileGetModTime, $l_sFileGetAccessTime, $l_sFileAttribute, $l_sFileCount, $l_sPrefList, $l_sSelDefVerPfx, $e_sSubSeq, $l_sSubSeq, $l_sDefLangCodeP Local $SS1, $SS2, $SS3, $SS4, $SS5, $SS6, $SS7, $SS8, $SS9, $SS10, $SS11, $SS12, $SS13, $SS14, $SS15, $SS16, $SS17, $SS18, $SS19, $SS20 Local $ReplCharGroup, $r_Underline, $r_Dash, $r_Period, $r_Space Local $aInput = StringSplit("R,A,S,H,N,D,O,C,T", ",") Local $aOutput = StringSplit("Read-only /, Archive /, System /, Hidden /, Normal /, Directory /, Offline /, Compressed /, Temporary /", ",") ;replace file's single letter attribute(s) with verbose list of labels For $i = 1 To $aInput[0] $sFileAttribute = StringReplace($sFileAttribute, $aInput[$i], $aOutput[$i], 0, $STR_CASESENSE) Next $sFileAttribute = StringStripWS(StringTrimRight($sFileAttribute, 2), 3) ;remove trailing '/' ;conversion of file's Properties Values to user meaningful display formats $sFileSize = _WinAPI_GetNumberFormat(0, $sFileSize, _WinAPI_CreateNumberFormatInfo(0, 0, 3, ' ', ',', 1)) & " bytes" $sFileGetCreateTime = _DateToMonth($sFileGetCreateTime[1]) & " " & $sFileGetCreateTime[2] & ", " & $sFileGetCreateTime[0] & " " & $sFileGetCreateTime[3] & ":" & _ $sFileGetCreateTime[4] & ":" & $sFileGetCreateTime[5] $sFileGetModTime = _DateToMonth($sFileGetModTime[1]) & " " & $sFileGetModTime[2] & ", " & $sFileGetModTime[0] & " " & $sFileGetModTime[3] & ":" & _ $sFileGetModTime[4] & ":" & $sFileGetModTime[5] $sFileGetAccessTime = _DateToMonth($sFileGetAccessTime[1]) & " " & $sFileGetAccessTime[2] & ", " & $sFileGetAccessTime[0] & " " & $sFileGetAccessTime[3] & ":" & _ $sFileGetAccessTime[4] & ":" & $sFileGetAccessTime[5] ;create Properties Values GUI $hAFVGUI = GUICreate("Append Version Number", 610, 820, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SYSMENU), $WS_GROUP) ;$hAFVGUI button controls $b_Folder = GUICtrlCreateButton("Working Folder", 5, 35, 100, 20) $b_TestSS = GUICtrlCreateButton(" Test Manual Changes", 461, 624, 128, 20) $b_RenameFile = GUICtrlCreateButton("Rename File", 540, 563, 60, 40, BitOR($BS_MULTILINE, $BS_VCENTER)) $b_LoadSS = GUICtrlCreateButton("Load", 282, 680, 46, 20) $b_PrevPfx = GUICtrlCreateButton("<", 133, 719, 16, 22) $b_NextPfx = GUICtrlCreateButton(">", 461, 719, 16, 22) $b_Edit_Ini = GUICtrlCreateButton("Edit INI File", 16, 762, 90, 18) $b_PrevFile = GUICtrlCreateButton("<", 195, 758, 16, 22) $b_NextFile = GUICtrlCreateButton(">", 399, 758, 16, 22) $b_Cancel = GUICtrlCreateButton("Close", 500, 762, 90, 18) $b_ClearRBFN = GUICtrlCreateButton("Clear", 10, 596, 32, 16) $b_ClearSSEdit = GUICtrlCreateButton("Clear", 151, 650, 32, 16) $b_SaveSSEntry = GUICtrlCreateButton("Add Sub", 317, 650, 70, 16, $BS_VCENTER) $b_DelSSEntry = GUICtrlCreateButton("Delete Sub", 389, 650, 70, 16, $BS_VCENTER) $ReplCharGroup = GUICtrlCreateGroup("Illegal Char Sub", 10, 626, 114, 120) $r_Underline = GUICtrlCreateRadio("Underline", 20, 641, 73, 25) $r_Dash = GUICtrlCreateRadio("Dash", 20, 666, 73, 25) $r_Period = GUICtrlCreateRadio("Period", 20, 691, 73, 25) $r_Space = GUICtrlCreateRadio("Space", 20, 716, 73, 25) GUICtrlSetState($r_Underline, $GUI_CHECKED) GUICtrlSetImage($b_LoadSS, @ScriptDir & "\Icons\filled green arrow up.ico") GUICtrlSetImage($b_TestSS, @ScriptDir & "\Icons\filled green arrow left.ico") GUICtrlSetFont($b_RenameFile, 8, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $DEFAULT_QUALITY) GUICtrlSetFont($b_Cancel, 8, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $DEFAULT_QUALITY) GUICtrlSetFont($b_TestSS, 8, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $DEFAULT_QUALITY) GUICtrlSetFont($b_PrevPfx, 8, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $DEFAULT_QUALITY) GUICtrlSetFont($b_NextPfx, 8, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $DEFAULT_QUALITY) GUICtrlSetFont($b_LoadSS, 8, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $DEFAULT_QUALITY) GUICtrlSetFont($b_Edit_Ini, 8, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $DEFAULT_QUALITY) GUICtrlSetFont($b_ClearSSEdit, 8, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $DEFAULT_QUALITY) GUICtrlSetFont($b_SaveSSEntry, 8, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $DEFAULT_QUALITY) GUICtrlSetFont($b_ClearRBFN, 8, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $DEFAULT_QUALITY) GUICtrlSetFont($ReplCharGroup, 8, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $DEFAULT_QUALITY) ;$hAFVGUI field labels GUICtrlCreateLabel("Windows File Name:", 10, 13, 100, 20, -1) GUICtrlCreateLabel("Original File Name:", 10, 63, 100, 20, -1) GUICtrlCreateLabel("File Internal Name:", 10, 88, 100, 20, -1) GUICtrlCreateLabel("Product Name:", 10, 113, 100, 20, -1) GUICtrlCreateLabel("File Description:", 10, 151, 100, 20, -1) GUICtrlCreateLabel("File Version:", 10, 190, 100, 20, -1) GUICtrlCreateLabel("Product Version:", 10, 210, 100, 20, -1) GUICtrlCreateLabel("Private Build:", 10, 230, 100, 20, -1) GUICtrlCreateLabel("Special Build:", 10, 250, 100, 20, -1) GUICtrlCreateLabel("Legal Copyright:", 10, 272, 100, 20, -1) GUICtrlCreateLabel("Company Name:", 10, 296, 100, -1) GUICtrlCreateLabel("Legal Trade Marks:", 10, 335, 95, 20, -1) GUICtrlCreateLabel("Comments:", 10, 390, 100, 50, -1) GUICtrlCreateLabel("File Size:", 10, 430, 100, 20, -1) GUICtrlCreateLabel("File Created:", 10, 450, 100, 20, -1) GUICtrlCreateLabel("File Last Modified:", 10, 470, 100, 20, -1) GUICtrlCreateLabel("File Last Accessed:", 10, 490, 95, 20, -1) GUICtrlCreateLabel("File Attribute(s):", 10, 510, 100, 20, -1) GUICtrlCreateLabel("DefLangCodePage:", 10, 530, 100, 20, -1) ;Sub Sequence Codes $SS1 = GUICtrlCreateLabel("N", 115, 13, 10, 20, $SS_CENTER) GUICtrlSetColor($SS1, $COLOR_RED) $SS2 = GUICtrlCreateLabel("O", 115, 63, 10, 20, $SS_CENTER) GUICtrlSetColor($SS2, $COLOR_RED) $SS3 = GUICtrlCreateLabel("I", 115, 88, 10, 20, $SS_CENTER) GUICtrlSetColor($SS3, $COLOR_RED) $SS4 = GUICtrlCreateLabel("P", 115, 113, 10, 20, $SS_CENTER) GUICtrlSetColor($SS4, $COLOR_RED) $SS5 = GUICtrlCreateLabel("e", 115, 151, 10, 20, $SS_CENTER) GUICtrlSetColor($SS5, $COLOR_RED) $SS6 = GUICtrlCreateLabel("f", 115, 190, 10, 20, $SS_CENTER) GUICtrlSetColor($SS6, $COLOR_RED) $SS7 = GUICtrlCreateLabel("p", 115, 210, 10, 20, $SS_CENTER) GUICtrlSetColor($SS7, $COLOR_RED) $SS8 = GUICtrlCreateLabel("b", 115, 230, 10, 20, $SS_CENTER) GUICtrlSetColor($SS8, $COLOR_RED) $SS9 = GUICtrlCreateLabel("B", 115, 250, 10, 20, $SS_CENTER) GUICtrlSetColor($SS9, $COLOR_RED) $SS10 = GUICtrlCreateLabel("L", 115, 272, 10, 20, $SS_CENTER) GUICtrlSetColor($SS10, $COLOR_RED) $SS11 = GUICtrlCreateLabel("c", 115, 296, 10, 20, $SS_CENTER) GUICtrlSetColor($SS11, $COLOR_RED) $SS12 = GUICtrlCreateLabel("k", 115, 335, 10, 20, $SS_CENTER) GUICtrlSetColor($SS12, $COLOR_RED) $SS13 = GUICtrlCreateLabel("z", 115, 430, 10, 20, $SS_CENTER) GUICtrlSetColor($SS13, $COLOR_RED) $SS14 = GUICtrlCreateLabel("C", 115, 450, 10, 20, $SS_CENTER) GUICtrlSetColor($SS14, $COLOR_RED) $SS15 = GUICtrlCreateLabel("M", 115, 470, 10, 20, $SS_CENTER) GUICtrlSetColor($SS15, $COLOR_RED) $SS16 = GUICtrlCreateLabel("A", 115, 490, 10, 20, $SS_CENTER) GUICtrlSetColor($SS16, $COLOR_RED) $SS17 = GUICtrlCreateLabel("a", 115, 510, 10, 20, $SS_CENTER) GUICtrlSetColor($SS17, $COLOR_RED) $SS18 = GUICtrlCreateLabel("g", 115, 530, 10, 20, $SS_CENTER) GUICtrlSetColor($SS18, $COLOR_RED) $SS19 = GUICtrlCreateLabel("d", 350, 450, 10, 20, $SS_CENTER) GUICtrlSetColor($SS19, $COLOR_RED) $SS20 = GUICtrlCreateLabel("t", 350, 470, 10, 20, $SS_CENTER) GUICtrlSetColor($SS20, $COLOR_RED) GUICtrlCreateLabel("Current Local Date", 365, 450, 110, 20, -1) GUICtrlCreateLabel("Current Local Time", 365, 470, 110, 20, -1) ;$hAFVGUI file's properties values $e_sFileName = _GUICtrlRichEdit_Create($hAFVGUI, $sFileName, 130, 10, 464, 20, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_READONLY), $WS_EX_CLIENTEDGE) $e_sFileFolder = _GUICtrlRichEdit_Create($hAFVGUI, $aFileArg[1], 130, 35, 464, 20, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_READONLY), $WS_EX_CLIENTEDGE) $e_sFileOrigFileName = _GUICtrlRichEdit_Create($hAFVGUI, $sFileOrigFileName, 130, 60, 464, 20, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_READONLY), $WS_EX_CLIENTEDGE) $e_sFileIntName = _GUICtrlRichEdit_Create($hAFVGUI, $sFileIntName, 130, 85, 464, 20, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_READONLY), $WS_EX_CLIENTEDGE) $e_sFileProductName = _GUICtrlRichEdit_Create($hAFVGUI, $sFileProductName, 130, 110, 464, 20, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_READONLY), $WS_EX_CLIENTEDGE) $e_sFileDescription = _GUICtrlRichEdit_Create($hAFVGUI, $sFileDescription, 130, 135, 464, 50, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $WS_VSCROLL, $ES_READONLY), $WS_EX_CLIENTEDGE) $l_sFileVersion = GUICtrlCreateLabel($sFileVersion, 130, 190, 464, 20, -1) $l_sFileProdVersion = GUICtrlCreateLabel($sFileProdVersion, 130, 210, 464, 20, -1) $l_sFilePrivBuild = GUICtrlCreateLabel($sFilePrivBuild, 130, 230, 464, 20, -1) $l_sFileSpecialBuild = GUICtrlCreateLabel($sFileSpecialBuild, 130, 250, 464, 20, -1) $e_sFileCopyright = _GUICtrlRichEdit_Create($hAFVGUI, $sFileCopyright, 130, 270, 464, 20, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_READONLY), $WS_EX_CLIENTEDGE) $e_sFileCompanyName = _GUICtrlRichEdit_Create($hAFVGUI, $sFileCompanyName, 130, 295, 464, 20, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $ES_READONLY), $WS_EX_CLIENTEDGE) $e_sFileLegTradeMrks = _GUICtrlRichEdit_Create($hAFVGUI, $sFileLegTradeMrks, 130, 320, 464, 50, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $WS_VSCROLL, $ES_READONLY), $WS_EX_CLIENTEDGE) $e_sFileComments = _GUICtrlRichEdit_Create($hAFVGUI, $sFileComments, 130, 375, 464, 50, BitOR($ES_LEFT, $ES_AUTOHSCROLL, $WS_VSCROLL, $ES_READONLY), $WS_EX_CLIENTEDGE) $l_sFileSize = GUICtrlCreateLabel($sFileSize, 130, 430, 180, 20, -1) $l_sFileGetCreateTime = GUICtrlCreateLabel($sFileGetCreateTime, 130, 450, 180, 20, -1) $l_sFileGetModTime = GUICtrlCreateLabel($sFileGetModTime, 130, 470, 180, 20, -1) $l_sFileGetAccessTime = GUICtrlCreateLabel($sFileGetAccessTime, 130, 490, 180, 20, -1) $l_sFileAttribute = GUICtrlCreateLabel($sFileAttribute, 130, 510, 180, 20, -1) $l_sDefLangCodeP = GUICtrlCreateLabel($sDefLangCodePage, 130, 530, 464, 20, -1) $l_sFileCount = GUICtrlCreateLabel("File " & $i_Index - 1 & " of " & $aFileArg[0] - 1, 212, 762, 186, 20, $SS_CENTER, -1) $l_sResFNLabel = GUICtrlCreateLabel("Resultant Base File Name", 195, 560, 220, 18, $SS_CENTER) $e_sResFN = _GUICtrlRichEdit_Create($hAFVGUI, "", 10, 574, 528, 20, BitOR($ES_LEFT, $ES_AUTOHSCROLL), $WS_EX_CLIENTEDGE) $l_sSubSeq = GUICtrlCreateLabel("Editable Working Sub Sequence", 195, 608, 220, 18, $SS_CENTER) $e_sSubSeq = _GUICtrlRichEdit_Create($hAFVGUI, "", 151, 622, 308, 26, BitOR($ES_CENTER, $ES_AUTOHSCROLL), $WS_EX_CLIENTEDGE) $l_sSelDefVerPfx = GUICtrlCreateLabel("Select Custom Sub Sequence", 195, 706, 220, 18, $SS_CENTER) $l_sPrefList = GUICtrlCreateLabel($t_FV, 151, 720, 308, 22, BitOR($SS_CENTER, $SS_SUNKEN)) GUICtrlSetColor($l_sFileCount, $COLOR_BLUE) GUICtrlSetFont($l_sPrefList, 10, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $DEFAULT_QUALITY) GUICtrlSetFont($l_sFileCount, 10, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $DEFAULT_QUALITY) GUICtrlSetFont($l_sSelDefVerPfx, 8, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $DEFAULT_QUALITY) GUICtrlSetFont($l_sSubSeq, 8, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $DEFAULT_QUALITY) GUICtrlSetFont($l_sResFNLabel, 8, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $DEFAULT_QUALITY) GUISetIcon($sFile) ;GUICtrlSetState($e_sSubSeq, $GUI_FOCUS) _GUICtrlRichEdit_SetSel($e_sSubSeq, 0, -1, False) _GUICtrlRichEdit_SetFont($e_sSubSeq, 12, "Arial") _GUICtrlRichEdit_SetSel($e_sSubSeq, -1, -1, False) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $b_Folder ShellExecute(@WindowsDir & "\explorer.exe", $aFileArg[1]) If @error <> 0 Then MsgBox(16, "Windows File Explorer Error", "Could not open Windows File Explorer.") Case $b_LoadSS _GUICtrlRichEdit_SetText($e_sSubSeq, GUICtrlRead($l_sPrefList)) _GUICtrlRichEdit_SetSel($e_sSubSeq, 0, -1, False) _GUICtrlRichEdit_SetFont($e_sSubSeq, 12, "Arial") _GUICtrlRichEdit_SetSel($e_sSubSeq, -1, -1, False) _Apply_SSW_To_File_Name($e_sSubSeq, $e_sResFN, $sFileFullDir, $sFileOrigFileName, $sFileIntName, $sFileProductName, $sFileDescription, $sFileVersion, $sFileProdVersion, $sFilePrivBuild, _ $sFileSpecialBuild, $sFileCopyright, $sFileCompanyName, $sFileLegTradeMrks, $sFileSize, $sFileGetCreateTime, $sFileGetModTime, $sFileGetAccessTime, $sFileAttribute, $sDefLangCodePage) Case $b_TestSS ;seq substitute $e_sSubSeq tokens with $sFilname _Apply_SSW_To_File_Name($e_sSubSeq, $e_sResFN, $sFileFullDir, $sFileOrigFileName, $sFileIntName, $sFileProductName, $sFileDescription, $sFileVersion, $sFileProdVersion, $sFilePrivBuild, _ $sFileSpecialBuild, $sFileCopyright, $sFileCompanyName, $sFileLegTradeMrks, $sFileSize, $sFileGetCreateTime, $sFileGetModTime, $sFileGetAccessTime, $sFileAttribute, $sDefLangCodePage) _GUICtrlRichEdit_SetSel($e_sSubSeq, 0, -1, False) _GUICtrlRichEdit_SetFont($e_sSubSeq, 12, "Arial") _GUICtrlRichEdit_SetSel($e_sSubSeq, -1, -1, False) Case $b_SaveSSEntry _GUICtrlRichEdit_SetSel($e_sSubSeq, 0, -1, False) _GUICtrlRichEdit_SetFont($e_sSubSeq, 12, "Arial") _GUICtrlRichEdit_SetSel($e_sSubSeq, -1, -1, False) $x = StringStripWS(_GUICtrlRichEdit_GetText($e_sSubSeq), 3) If $x <> "" Then $NH = False If UBound($aPrefix) > 0 Then For $i = 0 To UBound($aPrefix) - 1 If $x = $aPrefix[$i] Then MsgBox(64, "SUB SEQUENCE ALREADY EXISTS", $x & @CRLF & @CRLF & " already exists as a sub sequence to select.") $NH = True ExitLoop EndIf Next EndIf If Not $NH Then $Ans = MsgBox(36, "ADD NEW SUB SEQUENCE", "Are you sure that you want to ADD" & @CRLF & @CRLF & $x & @CRLF & @CRLF & "to the selection of sub sequences?") If $Ans = $IDYES Then ;add to array $f = _ArrayAdd($aPrefix, $x, 0, "] [", -1, 1) GUICtrlSetData($l_sPrefList, $aPrefix[$f]) _GUICtrlRichEdit_SetText($e_sSubSeq, "") _GUICtrlRichEdit_SetSel($e_sSubSeq, 0, -1, False) _GUICtrlRichEdit_SetFont($e_sSubSeq, 12, "Arial") _GUICtrlRichEdit_SetSel($e_sSubSeq, -1, -1, False) ;convert array to string $x = "[" & _ArrayToString($aPrefix, "] [") & "]" ;Inidelete contents of config.ini $NH = IniDelete($iniFolder, "format", "prefix") If Not $NH Then MsgBox(16, "FILE WRITE ERROR", "The config.ini file could not be written." & @CRLF & @CRLF & "Defaulting to program assigned" & @CRLF & @CRLF & _ $DefPrefixSet & @CRLF & @CRLF & "version prefixes") $aPrefix = _StringBetween($DefPrefixSet, "[", "]") $t_FV = $aPrefix[0] ; default prefix position in config.ini file. Default position can be modified by reordering or modifying prefix in default position. GUICtrlSetData($l_sPrefList, $t_FV) _GUICtrlRichEdit_SetText($e_sSubSeq, "") _GUICtrlRichEdit_SetSel($e_sSubSeq, 0, -1, False) _GUICtrlRichEdit_SetFont($e_sSubSeq, 12, "Arial") _GUICtrlRichEdit_SetSel($e_sSubSeq, -1, -1, False) Else ;iniWrite updated $x string to config.ini key IniWrite($iniFolder, "format", "prefix", $x) EndIf EndIf EndIf EndIf Case $b_DelSSEntry ;check entry is in array _GUICtrlRichEdit_SetSel($e_sSubSeq, 0, -1, False) _GUICtrlRichEdit_SetFont($e_sSubSeq, 12, "Arial") _GUICtrlRichEdit_SetSel($e_sSubSeq, -1, -1, False) $x = StringStripWS(_GUICtrlRichEdit_GetText($e_sSubSeq), 3) If $x <> "" Then $NH = False If UBound($aPrefix) > 0 Then For $j = 0 To UBound($aPrefix) - 1 If $x = $aPrefix[$j] Then $NH = True $f = $j ExitLoop EndIf Next EndIf If Not $NH Then MsgBox(64, "NOT FOUND", "The sub sequence" & @CRLF & @CRLF & $x & @CRLF & @CRLF & "is not found in the selection of sub sequences.") If $NH Then $Ans = MsgBox(36, "DELETE SUB SEQUENCE", "Are you sure that you want to DELETE" & @CRLF & @CRLF & $x & @CRLF & @CRLF & "from the selection of sub sequences?") If $Ans = $IDYES Then _ArrayDelete($aPrefix, $f) $NH = IniDelete($iniFolder, "format", "prefix") If Not $NH Then MsgBox(16, "FILE WRITE ERROR", "The config.ini file section could not be deleted." & @CRLF & @CRLF & "Defaulting to program assigned" & @CRLF & @CRLF & _ $DefPrefixSet & @CRLF & @CRLF & "version prefixes") $aPrefix = _StringBetween($DefPrefixSet, "[", "]") $t_FV = $aPrefix[0] ; default prefix position in config.ini file. Default position can be modified by reordering or modifying prefix in default position. GUICtrlSetData($l_sPrefList, $t_FV) Else If UBound($aPrefix) > 0 Then GUICtrlSetData($l_sPrefList, $aPrefix[0]) _GUICtrlRichEdit_SetText($e_sSubSeq, "") _GUICtrlRichEdit_SetSel($e_sSubSeq, 0, -1, False) _GUICtrlRichEdit_SetFont($e_sSubSeq, 12, "Arial") _GUICtrlRichEdit_SetSel($e_sSubSeq, -1, -1, False) ;convert array to string $x = "[" & _ArrayToString($aPrefix, "] [") & "]" ;iniWrite updated $x string to config.ini key IniWrite($iniFolder, "format", "prefix", $x) Else $t_FV = "" GUICtrlSetData($l_sPrefList, $t_FV) _GUICtrlRichEdit_SetText($e_sSubSeq, "") _GUICtrlRichEdit_SetSel($e_sSubSeq, 0, -1, False) _GUICtrlRichEdit_SetFont($e_sSubSeq, 12, "Arial") _GUICtrlRichEdit_SetSel($e_sSubSeq, -1, -1, False) EndIf EndIf EndIf EndIf EndIf Case $b_RenameFile If _GUICtrlRichEdit_GetText($e_sResFN) <> "" Then $sFileFullDir = $aFileArg[1] & "\" & $aFileArg[$i_Index] $BadChar = _Rename_File($aFileArg, $sFileFullDir, $e_sResFN, $i_Index) If Not $BadChar Then _Update_Properties_View($aFileArg, $aInput, $aOutput, $i_Index, _ $sFileName, $sFileFullDir, $sFileOrigFileName, $sFileIntName, $sFileProductName, $sFileDescription, _ $sFileVersion, $sFileProdVersion, $sFilePrivBuild, $sFileSpecialBuild, $sFileCopyright, $sFileCompanyName, _ $sFileLegTradeMrks, $sFileComments, $sFileSize, $sFileGetCreateTime, $sFileGetModTime, $sFileGetAccessTime, $sFileAttribute, _ $sDefLangCodePage, $e_sFileName, $e_sFileFolder, $e_sFileOrigFileName, $e_sFileIntName, $e_sFileProductName, $e_sFileDescription, _ $l_sFileVersion, $l_sFileProdVersion, $l_sFilePrivBuild, $l_sFileSpecialBuild, $e_sFileCopyright, $e_sFileCompanyName, _ $e_sFileLegTradeMrks, $e_sFileComments, $l_sFileSize, $l_sFileGetCreateTime, $l_sFileGetModTime, _ $l_sFileGetAccessTime, $l_sFileAttribute, $l_sFileCount, $l_sDefLangCodeP) ;GUICtrlSetState($e_sSubSeq, $GUI_FOCUS) _GUICtrlRichEdit_SetSel($e_sSubSeq, 0, -1, False) _GUICtrlRichEdit_SetFont($e_sSubSeq, 12, "Arial") _GUICtrlRichEdit_SetSel($e_sSubSeq, -1, -1, False) EndIf EndIf Case $b_ClearSSEdit _GUICtrlRichEdit_SetText($e_sSubSeq, "") _GUICtrlRichEdit_SetText($e_sResFN, "") _GUICtrlRichEdit_SetSel($e_sSubSeq, 0, -1, False) _GUICtrlRichEdit_SetFont($e_sSubSeq, 12, "Arial") _GUICtrlRichEdit_SetSel($e_sSubSeq, -1, -1, False) Case $b_ClearRBFN _GUICtrlRichEdit_SetText($e_sResFN, "") _GUICtrlRichEdit_SetSel($e_sSubSeq, 0, -1, False) _GUICtrlRichEdit_SetFont($e_sSubSeq, 12, "Arial") _GUICtrlRichEdit_SetSel($e_sSubSeq, -1, -1, False) Case $b_PrevPfx ;$aPrefix assign new $t_FV $x = _ArraySearch($aPrefix, $t_FV, 0, 0, 0, 0, 1, 2) If $x > 0 Then $t_FV = $aPrefix[$x - 1] GUICtrlSetData($l_sPrefList, $t_FV) EndIf Case $b_NextPfx ;aPrefix assign new $t_FV $x = _ArraySearch($aPrefix, $t_FV, 0, 0, 0, 0, 1, 2) If $x < UBound($aPrefix) - 1 Then $t_FV = $aPrefix[$x + 1] GUICtrlSetData($l_sPrefList, $t_FV) EndIf Case $r_Underline If GUICtrlRead($r_Underline) = $GUI_CHECKED Then $t_RC = $aRepChars[0] _Apply_SSW_To_File_Name($e_sSubSeq, $e_sResFN, $sFileFullDir, $sFileOrigFileName, $sFileIntName, $sFileProductName, $sFileDescription, $sFileVersion, $sFileProdVersion, $sFilePrivBuild, _ $sFileSpecialBuild, $sFileCopyright, $sFileCompanyName, $sFileLegTradeMrks, $sFileSize, $sFileGetCreateTime, $sFileGetModTime, $sFileGetAccessTime, $sFileAttribute, $sDefLangCodePage) EndIf Case $r_Dash If GUICtrlRead($r_Dash) = $GUI_CHECKED Then $t_RC = $aRepChars[1] _Apply_SSW_To_File_Name($e_sSubSeq, $e_sResFN, $sFileFullDir, $sFileOrigFileName, $sFileIntName, $sFileProductName, $sFileDescription, $sFileVersion, $sFileProdVersion, $sFilePrivBuild, _ $sFileSpecialBuild, $sFileCopyright, $sFileCompanyName, $sFileLegTradeMrks, $sFileSize, $sFileGetCreateTime, $sFileGetModTime, $sFileGetAccessTime, $sFileAttribute, $sDefLangCodePage) EndIf Case $r_Period If GUICtrlRead($r_Period) = $GUI_CHECKED Then $t_RC = $aRepChars[2] _Apply_SSW_To_File_Name($e_sSubSeq, $e_sResFN, $sFileFullDir, $sFileOrigFileName, $sFileIntName, $sFileProductName, $sFileDescription, $sFileVersion, $sFileProdVersion, $sFilePrivBuild, _ $sFileSpecialBuild, $sFileCopyright, $sFileCompanyName, $sFileLegTradeMrks, $sFileSize, $sFileGetCreateTime, $sFileGetModTime, $sFileGetAccessTime, $sFileAttribute, $sDefLangCodePage) EndIf Case $r_Space If GUICtrlRead($r_Space) = $GUI_CHECKED Then $t_RC = $aRepChars[3] _Apply_SSW_To_File_Name($e_sSubSeq, $e_sResFN, $sFileFullDir, $sFileOrigFileName, $sFileIntName, $sFileProductName, $sFileDescription, $sFileVersion, $sFileProdVersion, $sFilePrivBuild, _ $sFileSpecialBuild, $sFileCopyright, $sFileCompanyName, $sFileLegTradeMrks, $sFileSize, $sFileGetCreateTime, $sFileGetModTime, $sFileGetAccessTime, $sFileAttribute, $sDefLangCodePage) EndIf Case $b_Edit_Ini ;_Create_Edit_FormatINI_File() If FileExists(@SystemDir & "\notepad.exe") Then If FileExists($iniFolder) Then ;open for editing with Notepad ShellExecuteWait(@SystemDir & "\notepad.exe", $iniFolder, "", $SHEX_OPEN) If @error <> 0 Then MsgBox(16, "FILE OPEN ERROR", "Could not open config.ini with Windows Notepad editor.") Else _LoadFormatFileData() GUICtrlSetData($l_sPrefList, $t_FV) EndIf Else ;create new file or accept default '_v'? $Ans = MsgBox(36, "FILE NOT FOUND ERROR", "The version prefix config.ini file could not be found." & @CRLF & @CRLF & _ "Proceed to create a new config.ini file (Y) or continue with the default version prefix formats (N)?") If $Ans = $IDYES Then ;create new INI file _Create_Default_PrefixINI_File() GUICtrlSetData($l_sPrefList, $t_FV) _GUICtrlRichEdit_SetText($e_sSubSeq, $aPrefix[0]) _GUICtrlRichEdit_SetSel($e_sSubSeq, 0, -1, False) _GUICtrlRichEdit_SetFont($e_sSubSeq, 12, "Arial") _GUICtrlRichEdit_SetSel($e_sSubSeq, -1, -1, False) Else ;assign values to $aPrefix array $aPrefix = _StringBetween($DefPrefixSet, "[", "]") ;assign default prefix $t_FV = $aPrefix[0] ; default prefix position in config.ini file. GUICtrlSetData($l_sPrefList, $t_FV) _GUICtrlRichEdit_SetText($e_sSubSeq, $aPrefix[0]) _GUICtrlRichEdit_SetSel($e_sSubSeq, 0, -1, False) _GUICtrlRichEdit_SetFont($e_sSubSeq, 12, "Arial") _GUICtrlRichEdit_SetSel($e_sSubSeq, -1, -1, False) EndIf EndIf Else ; notepad missing of other system text editor is used instead MsgBox(16, "FILE NOT FOUND ERROR", "Windows Notepad editor could not be found.") EndIf Case $b_PrevFile If $i_Index > 2 Then _GUICtrlRichEdit_SetText($e_sResFN, "") $i_Index -= 1 $sFileFullDir = $aFileArg[1] & "\" & $aFileArg[$i_Index] _Update_Properties_View($aFileArg, $aInput, $aOutput, $i_Index, _ $sFileName, $sFileFullDir, $sFileOrigFileName, $sFileIntName, $sFileProductName, $sFileDescription, _ $sFileVersion, $sFileProdVersion, $sFilePrivBuild, $sFileSpecialBuild, $sFileCopyright, $sFileCompanyName, _ $sFileLegTradeMrks, $sFileComments, $sFileSize, $sFileGetCreateTime, $sFileGetModTime, $sFileGetAccessTime, $sFileAttribute, _ $sDefLangCodePage, $e_sFileName, $e_sFileFolder, $e_sFileOrigFileName, $e_sFileIntName, $e_sFileProductName, $e_sFileDescription, _ $l_sFileVersion, $l_sFileProdVersion, $l_sFilePrivBuild, $l_sFileSpecialBuild, $e_sFileCopyright, $e_sFileCompanyName, _ $e_sFileLegTradeMrks, $e_sFileComments, $l_sFileSize, $l_sFileGetCreateTime, $l_sFileGetModTime, _ $l_sFileGetAccessTime, $l_sFileAttribute, $l_sFileCount, $l_sDefLangCodeP) _Apply_SSW_To_File_Name($e_sSubSeq, $e_sResFN, $sFileFullDir, $sFileOrigFileName, $sFileIntName, $sFileProductName, $sFileDescription, $sFileVersion, $sFileProdVersion, $sFilePrivBuild, _ $sFileSpecialBuild, $sFileCopyright, $sFileCompanyName, $sFileLegTradeMrks, $sFileSize, $sFileGetCreateTime, $sFileGetModTime, $sFileGetAccessTime, $sFileAttribute, $sDefLangCodePage) ;GUICtrlSetState($e_sSubSeq, $GUI_FOCUS) _GUICtrlRichEdit_SetSel($e_sSubSeq, 0, -1, False) _GUICtrlRichEdit_SetFont($e_sSubSeq, 12, "Arial") _GUICtrlRichEdit_SetSel($e_sSubSeq, -1, -1, False) EndIf Case $b_NextFile If $i_Index < $aFileArg[0] Then _GUICtrlRichEdit_SetText($e_sResFN, "") $i_Index += 1 $sFileFullDir = $aFileArg[1] & "\" & $aFileArg[$i_Index] _Update_Properties_View($aFileArg, $aInput, $aOutput, $i_Index, _ $sFileName, $sFileFullDir, $sFileOrigFileName, $sFileIntName, $sFileProductName, $sFileDescription, _ $sFileVersion, $sFileProdVersion, $sFilePrivBuild, $sFileSpecialBuild, $sFileCopyright, $sFileCompanyName, _ $sFileLegTradeMrks, $sFileComments, $sFileSize, $sFileGetCreateTime, $sFileGetModTime, $sFileGetAccessTime, $sFileAttribute, _ $sDefLangCodePage, $e_sFileName, $e_sFileFolder, $e_sFileOrigFileName, $e_sFileIntName, $e_sFileProductName, $e_sFileDescription, _ $l_sFileVersion, $l_sFileProdVersion, $l_sFilePrivBuild, $l_sFileSpecialBuild, $e_sFileCopyright, $e_sFileCompanyName, _ $e_sFileLegTradeMrks, $e_sFileComments, $l_sFileSize, $l_sFileGetCreateTime, $l_sFileGetModTime, _ $l_sFileGetAccessTime, $l_sFileAttribute, $l_sFileCount, $l_sDefLangCodeP) _Apply_SSW_To_File_Name($e_sSubSeq, $e_sResFN, $sFileFullDir, $sFileOrigFileName, $sFileIntName, $sFileProductName, $sFileDescription, $sFileVersion, $sFileProdVersion, $sFilePrivBuild, _ $sFileSpecialBuild, $sFileCopyright, $sFileCompanyName, $sFileLegTradeMrks, $sFileSize, $sFileGetCreateTime, $sFileGetModTime, $sFileGetAccessTime, $sFileAttribute, $sDefLangCodePage) ;GUICtrlSetState($e_sSubSeq, $GUI_FOCUS) _GUICtrlRichEdit_SetSel($e_sSubSeq, 0, -1, False) _GUICtrlRichEdit_SetFont($e_sSubSeq, 12, "Arial") _GUICtrlRichEdit_SetSel($e_sSubSeq, -1, -1, False) EndIf Case $b_Cancel ExitLoop ;return to file(s) selection prompt EndSwitch WEnd GUIDelete($hAFVGUI) EndFunc ;==>_Append_File_Version Func _Apply_SSW_To_File_Name($e_sSubSeq, $e_sResFN, $sFileFullDir, $sFileOrigFileName, $sFileIntName, $sFileProductName, $sFileDescription, $sFileVersion, $sFileProdVersion, $sFilePrivBuild, _ $sFileSpecialBuild, $sFileCopyright, $sFileCompanyName, $sFileLegTradeMrks, $sFileSize, $sFileGetCreateTime, $sFileGetModTime, $sFileGetAccessTime, $sFileAttribute, $sDefLangCodePage) Local $sNewName = "", $sub, $NewPipe = False Local $aSub, $sSubSeq, $f_Drive, $f_Dir, $f_Name, $f_Ext, $time, $date, $timedate, $Trunc = "", $Asterisk = False, $Found, $Pos Local $aSPath ;just need $f_name Local $ExtFileExt[] = [".action", ".apk", ".app", ".bat", ".bin", ".cmd", ".com", ".command", ".cpl", ".csh", ".exe", ".gadget", ".inf", ".ins", ".inx", ".ipa", ".isu", ".job", ".jse", ".ksh", ".lnk", ".msc", _ ".msi", ".msp", ".mst", ".osx", ".out", ".paf", ".pif", ".prg", ".ps1", ".reg", ".rgs", ".run", ".scr", ".sct", ".shb", ".shs", ".u3p", ".vb", ".vbe", ".vbs", ".vbscript", ".workflow", _ ".ws", ".wsf", ".wsh", ".oxe", ".73k", ".89k", ".a6p", ".ac", ".acc", ".acr", ".actm", ".ahk", ".air", ".app", ".arscript", ".as", ".asb", ".awk", ".azw2", ".beam", ".btm", ".cel", ".celx", _ ".chm", ".cof", ".crt", ".dek", ".dld", ".dmc", ".docm", ".dotm", ".dxl", ".ear", ".ebm", ".ebs", ".ebs2", ".ecf", ".eham", ".elf", ".es", ".ex4", ".exopc", ".ezs", ".fas", _ ".fky", ".fpi", ".frs", ".fxp", ".gs", ".ham", ".hms", ".hpf", ".hta", ".iim", ".ipf", ".isp", ".jar", ".js", ".jsx", ".kix", ".lo", ".ls", ".mam", ".mcr", ".mel", ".mpx", ".mrc", ".ms", ".mxe", _ ".nexe", ".obs", ".ore", ".otm", ".pex", ".plx", ".potm", ".ppam", ".ppsm", ".pptm", ".prc", ".pvd", ".pwc", ".pyc", ".pyo", ".qpx", ".rbx", ".rox", ".rpj", ".s2a", ".sbs", ".sca", ".scar", _ ".scb", ".script", ".smm", ".spr", ".tcp", ".thm", ".tlb", ".tms", ".udf", ".upx", ".url", ".vlx", ".vpm", ".wcm", ".widget", ".wiz", ".wpk", ".wpm", ".xap", ".xbap", ".xlam", ".xlm", _ ".xlsm", ".xltm", ".xqt", ".xqt", ".xys", ".zl9"] ; list of all Windows executable files and common extensions found $sSubSeq = _GUICtrlRichEdit_GetText($e_sSubSeq) $aSub = StringSplit($sSubSeq, "") If @error Then MsgBox(16, "READ ERROR", "The subsitute sequence string is malformed.") Else For $i = 1 To UBound($aSub) - 1 $sub = Asc($aSub[$i]) If $sub <> 47 Then ; "/" Switch $sub Case 124 ;"|" $NewPipe = True Case 42 ;"*" If $Asterisk = False Then $Asterisk = True ElseIf $Asterisk = True Then If StringLen($sNewName) > Number($Trunc) Then $sNewName = StringTrimRight($sNewName, Number($Trunc)) Else MsgBox(16, "TRUNCATION TOO LONG", "The truncation length of '*" & $Trunc & "*' is longer than the preceding character string it is operating on") EndIf $Trunc = "" $Asterisk = False EndIf Case 48 To 57 ; 0 to 9 If $sNewName = True And $Asterisk = True Then $Trunc = $Trunc & Chr($sub) Else $sNewName = $sNewName & Chr($sub) EndIf Case 78 ;N If $NewPipe = True Then $aSPath = _PathSplit($sFileFullDir, $f_Drive, $f_Dir, $f_Name, $f_Ext) $sNewName = $sNewName & $f_Name $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case 79 ;O If $NewPipe = True Then $Found = False $aSPath = _PathSplit($sFileOrigFileName, $f_Drive, $f_Dir, $f_Name, $f_Ext) For $j = 0 To UBound($ExtFileExt) - 1 If $ExtFileExt[$j] = $f_Ext Then $sNewName = $sNewName & $f_Name $Found = True ExitLoop EndIf Next If $Found = False Then $sNewName = $sNewName & $sFileOrigFileName $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case 73 ; I If $NewPipe = True Then $Found = False $aSPath = _PathSplit($sFileIntName, $f_Drive, $f_Dir, $f_Name, $f_Ext) For $k = 0 To UBound($ExtFileExt) - 1 If $ExtFileExt[$k] = $f_Ext Then $sNewName = $sNewName & $f_Name $Found = True ExitLoop EndIf Next If $Found = False Then $sNewName = $sNewName & $sFileIntName $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case 80 ;P If $NewPipe = True Then $sNewName = $sNewName & $sFileProductName $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case 116 ;t If $NewPipe = True Then $timedate = _Date_Time_GetLocalTime() $time = StringReplace(_Date_Time_SystemTimeToTimeStr($timedate), ":", "") $sNewName = $sNewName & $time $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case 100 ;d If $NewPipe = True Then $timedate = _Date_Time_GetLocalTime() $date = StringReplace(_Date_Time_SystemTimeToDateStr($timedate, 1), "/", "-") $sNewName = $sNewName & $date $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case 101 ;e If $NewPipe = True Then $sNewName = $sNewName & $sFileDescription $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case 102 ;f If $NewPipe = True Then $sNewName = $sNewName & $sFileVersion $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case 112 ;p If $NewPipe = True Then $sNewName = $sNewName & $sFileProdVersion $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case 98 ;b If $NewPipe = True Then $sNewName = $sNewName & $sFilePrivBuild $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case 66 ;B If $NewPipe = True Then $sNewName = $sNewName & $sFileSpecialBuild $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case 76 ;L If $NewPipe = True Then $sNewName = $sNewName & $sFileCopyright $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case 99 ;c If $NewPipe = True Then $sNewName = $sNewName & $sFileCompanyName $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case 107 ;k If $NewPipe = True Then $sNewName = $sNewName & $sFileLegTradeMrks $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case 122 ;z If $NewPipe = True Then $sNewName = $sNewName & $sFileSize $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case 67 ;C If $NewPipe = True Then $sFileGetCreateTime = StringReplace($sFileGetCreateTime, ":", "", 2) $sNewName = $sNewName & $sFileGetCreateTime $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case 77 ;M If $NewPipe = True Then $sFileGetModTime = StringReplace($sFileGetModTime, ":", "", 2) $sNewName = $sNewName & $sFileGetModTime $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case 65 ;A If $NewPipe = True Then $sFileGetAccessTime = StringReplace($sFileGetAccessTime, ":", "", 2) $sNewName = $sNewName & $sFileGetAccessTime $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case 97 ;a If $NewPipe = True Then $sNewName = $sNewName & $sFileAttribute $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case 103 ;g If $NewPipe = True Then $sNewName = $sNewName & $sDefLangCodePage $NewPipe = False Else $sNewName = $sNewName & Chr($sub) EndIf Case Else ; if not a sub seq character $sNewName = $sNewName & Chr($sub) $NewPipe = False EndSwitch EndIf Next ;removes illegal characters in the Resultant Base file name For $h = 1 To UBound($aXChars) - 1 $Pos = StringInStr($sNewName, $aXChars[$h], 1) If $Pos > 0 Then $sNewName = StringReplace($sNewName, $Pos, $t_RC, 0, 0) EndIf Next _GUICtrlRichEdit_SetText($e_sResFN, $sNewName) EndIf EndFunc ;==>_Apply_SSW_To_File_Name Func _Create_Default_PrefixINI_File() Local $LineReadPfx, $LineReadRChar, $LineWrite Local $INI_line1 = $DefPrefixSet Local $INI_line2 = ";The letter just after the pipe is a rep code. All text following to the left of the single letter rep code and up to the next" Local $INI_line3 = ";pipe is read as litteral text in the renaming of the file." Local $INI_line4 = ";/ signifies the end of the that sub sequence to be applied to the renaming of a file." Local $INI_line5 = ";Ex., notepad.exe with a file version number of 8.2.1.3. We will be applying the sub sequence of |N_fv|f/" Local $INI_line6 = ";The pipe '|' is always followed by a rep code, 'N' in this example." Local $INI_line7 = ";The N represents the file's base name to be substituted, 'notepad' in this example." Local $INI_line8 = ";The characters '_fv' following the 'N', and up to the next pipe, is read as litteral text to appear in the final renaming." Local $INI_line9 = ";So far then, we have: 'notepad_fv'formed as part of the final notepad renaming." Local $INI_line10 = ";Then, the pipe following '_fv' indicates a new rep code, 'f' following the pipe." Local $INI_line11 = ";'f'represents notepad's version number. The / following f indicates the end of the sub sequence." Local $INI_line12 = ";So, the file renaming will be 'notepad_fv8.2.1.3'" Local $INI_line13 = ";Each sub sequence for use in the program is separated by bracket delimiters []." Local $INI_line14 = ";The program can select different sub sequences to be applied to a file name." Local $INI_line15 = ";The first bracket group is the default sub sequence." Local $INI_line16 = $DefReplChar ;write config.ini file $LineWrite = IniWrite($iniFolder, "format", "prefix", $INI_line1 & @CRLF & @CRLF & $INI_line2 & @CRLF & $INI_line3 & @CRLF & $INI_line4 & @CRLF & @CRLF & $INI_line5 & _ @CRLF & $INI_line6 & @CRLF & $INI_line7 & @CRLF & $INI_line8 & @CRLF & $INI_line9 & $INI_line10 & @CRLF & $INI_line11 & @CRLF & $INI_line12 & @CRLF & @CRLF & _ $INI_line13 & @CRLF & $INI_line14 & @CRLF & $INI_line15 & @CRLF & @CRLF) If Not $LineWrite Then MsgBox(16, "FILE WRITE ERROR", "The config.ini file could not be written." & @CRLF & @CRLF & "Defaulting to program assigned" & @CRLF & @CRLF & _ $DefPrefixSet & @CRLF & @CRLF & "version prefixes") $aPrefix = _StringBetween($DefPrefixSet, "[", "]", 0, True) $t_FV = $aPrefix[0] ; default prefix position in config.ini file. Default position can be modified by reordering or modifying prefix in default position. Else ;read values from config.ini file $LineReadPfx = IniRead($iniFolder, "format", "prefix", $DefPrefixSet) ;assign values to $aPrefix array $aPrefix = _StringBetween($LineReadPfx, "[", "]") ;assign default prefix $t_FV = $aPrefix[0] ; default prefix position in config.ini file. Default position can be modified by reordering or modifying prefix in default position. EndIf $LineWrite = IniWrite($iniFolder, "repchar", "replchar", $INI_line16) If Not $LineWrite Then MsgBox(16, "FILE WRITE ERROR", "The config.ini file could not be written." & @CRLF & @CRLF & "Defaulting to program assigned" & @CRLF & @CRLF & _ $DefReplChar & @CRLF & @CRLF & "replacement character.") $aRepChars = _StringBetween($DefReplChar, "[", "]", 0, True) $t_RC = $aRepChars[0] ; default prefix eplacement character in config.ini file. Default position can be modified by reordering or modifying character in default position. Else ;read values from config.ini file $LineReadRChar = IniRead($iniFolder, "repchar", "replchar", $DefReplChar) ;assign values to $aRepChars array $aRepChars = _StringBetween($LineReadRChar, "[", "]") ;assign default replacement character $t_RC = $aRepChars[0] ; default replacement character in config.ini file. Default position can be modified by reordering or modifying character in default position. EndIf EndFunc ;==>_Create_Default_PrefixINI_File Func _Load_Any_Parameters() Local $aPath, $f_Drive, $f_Dir, $f_Name, $f_Ext, $All_Files_Found = True _LoadFormatFileData() If $CmdLIne[0] > 0 Then ;pass file parameter, if existing, to the program, bypassing select file(s) prompt GUI $aPath = _PathSplit($CmdLine[1], $f_Drive, $f_Dir, $f_Name, $f_Ext) ReDim $afile[$CmdLine[0] + 2] $afile[0] = $CmdLIne[0] + 1 If $f_Drive = "" Or $f_Dir = "" Then $afile[1] = @WorkingDir & "\" Else $afile[1] = $f_Drive & $f_Dir EndIf $afile[2] = $f_Name & $f_Ext For $i = 3 To UBound($afile) - 1 $afile[$i] = $CmdLIne[$i - 1] Next For $k = 2 To UBound($afile) - 1 If Not FileExists($afile[1] & $afile[$k]) Then MsgBox(16, "FILE NOT FOUND", "The argument file parameter" & @CRLF & @CRLF & $afile[1] & $afile[$k] & @CRLF & @CRLF & _ "passed to the program could not be found.") $All_Files_Found = False ExitLoop EndIf Next If $All_Files_Found Then _Append_File_Version($afile) EndIf EndIf _Open_File_Names() EndFunc ;==>_Load_Any_Parameters Func _LoadFormatFileData() Local $LineReadPfx, $LineReadRChar, $Moved, $temp If FileExists($iniFolder) Then $LineReadPfx = IniRead($iniFolder, "format", "prefix", "Error - prefix") $LineReadRChar = IniRead($iniFolder, "repchar", "replchar", "Error - repchar") If $LineReadPfx = "Error - prefix" Or $LineReadRChar = "Error - repchar" Then MsgBox(16, "config.ini FILE ERROR", "config.ini file is missing all or some values." & @CRLF & @CRLF & _ "Defaulting to program default version prefixes:" & @CRLF & @CRLF & $DefPrefixSet & @CRLF & @CRLF & "and replacement characters:" & @CRLF & @CRLF & $DefReplChar) $LineReadPfx = $DefPrefixSet $LineReadRChar = $DefReplChar $aPrefix = _StringBetween($LineReadPfx, "[", "]", 0, True) $aRepChars = _StringBetween($LineReadRChar, "[", "]", 0, True) $temp = Random(65, 122, 1) & Random(0, 9, 1) & Random(65, 122, 1) & Random(0, 9, 1) ; rename config.ini file $Moved = FileMove($iniFolder, @ScriptDir & "\Ini Files\config" & $temp & ".ini", $FC_OVERWRITE) If $Moved Then ;no renaming error MsgBox(64, "FILE RENAMED", $iniFolder & @CRLF & @CRLF & "file was renamed to" & @CRLF & @CRLF & "config" & $temp & ".ini" & @CRLF & @CRLF & _ "A new config.ini file will be re-created with default version prefixes:" & @CRLF & @CRLF & $DefPrefixSet & _ "and replacement characters:" & @CRLF & @CRLF & $DefReplChar) Else MsgBox(16, "FILE RENAMING ERROR", $iniFolder & @CRLF & @CRLF & "could not be renamed to" & @CRLF & @CRLF & "config" & $temp & ".ini") EndIf _Create_Default_PrefixINI_File() Else $aPrefix = _StringBetween($LineReadPfx, "[", "]", 0, True) $aRepChars = _StringBetween($LineReadRChar, "[", "]", 0, True) If @error Then ;not strings found with _StringBetween MsgBox(16, "config.ini FILE ERROR", "config.ini file's IMPORTED values are missing all or some matching delimiter brackets '[ ]' " & _ "surrounding values. keyline can not be parsed." & @CRLF & @CRLF & "Defaulting to program default version prefixes:" & @CRLF & @CRLF & $DefPrefixSet & _ "and replacement characters:" & @CRLF & @CRLF & $DefReplChar) $aPrefix = _StringBetween($DefPrefixSet, "[", "]") $aRepChars = _StringBetween($LineReadRChar, "[", "]", 0, True) $temp = Random(65, 122, 1) & Random(0, 9, 1) & Random(65, 122, 1) & Random(0, 9, 1) ; rename config.ini file $Moved = FileMove($iniFolder, @ScriptDir & "\Ini Files\config" & $temp & ".ini", $FC_OVERWRITE) If $Moved Then ;no renaming error MsgBox(64, "FILE RENAMED", $iniFolder & @CRLF & @CRLF & "file was renamed to" & @CRLF & @CRLF & "config" & $temp & ".ini" & @CRLF & @CRLF & _ "A new config.ini file will be re-created with default version prefixes:" & @CRLF & @CRLF & $DefPrefixSet & _ "and replacement characters:" & @CRLF & @CRLF & $DefReplChar) Else MsgBox(16, "FILE RENAMING ERROR", $iniFolder & @CRLF & @CRLF & "could not be renamed to" & @CRLF & @CRLF & "config" & $temp & ".ini") EndIf _Create_Default_PrefixINI_File() Else $t_RC = $aRepChars[0] $t_FV = $aPrefix[0] EndIf EndIf Else ;create missing config.ini file MsgBox(64, "config.ini FILE NOT FOUND", "The " & @CRLF & @CRLF & $iniFolder & @CRLF & @CRLF & "file can not be found." & @CRLF & @CRLF & "A new config.ini file will be created.") _Create_Default_PrefixINI_File() EndIf EndFunc ;==>_LoadFormatFileData ;select file to append file version to Func _Open_File_Names() Local $b_Choose, $b_Cancel, $id_Lab1 $hOFNGUI = GUICreate("", 200, 200, -1, -1, -1, $WS_EX_WINDOWEDGE) $b_Choose = GUICtrlCreateButton("Select File(s)", 55, 130, 90, 20, $BS_DEFPUSHBUTTON) $b_Cancel = GUICtrlCreateButton("Close", 55, 156, 90, 20) $id_Lab1 = GUICtrlCreateLabel("Select File(s) to Rename", 10, 40, 180, 60, $SS_CENTER) GUICtrlSetColor($id_Lab1, $COLOR_BLACK) GUICtrlSetFont($id_Lab1, 12, $FW_NORMAL, $GUI_FONTNORMAL, "Arial", $DEFAULT_QUALITY) GUISetIcon($sFile) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $b_Choose GUISetState(@SW_HIDE) $afile = _WinAPI_GetOpenFileName("Select File(s) to Rename", "All Files (*.*)", ".", "", "", 1, BitOR($OFN_ALLOWMULTISELECT, $OFN_EXPLORER), 0, $hOFNGUI) ;Cancelling Open File Dialog sets the @error flag to value of 10 If @error Then If @error <> 10 Then MsgBox(16, "FILE SELECT DIALOG OPEN ERROR", "Open Files dialog ERROR") Else GUISetState(@SW_SHOW) EndIf Else _Append_File_Version($afile) GUISetState(@SW_SHOW) EndIf Case $b_Cancel ExitLoop EndSwitch WEnd GUIDelete($hOFNGUI) EndFunc ;==>_Open_File_Names Func _Rename_File(ByRef $aFileArg, $sFileFullDir, $e_sResFN, $i_Index) Local $FN, $Pos, $sDir, $Renamed, $NewPath = "", $BadChar = False Local $f_Drive, $f_Dir, $f_Name, $f_Ext Local $aSPath = _PathSplit($sFileFullDir, $f_Drive, $f_Dir, $f_Name, $f_Ext) $FN = _GUICtrlRichEdit_GetText($e_sResFN) ;file name w/o ext $sDir = $f_Drive & $f_Dir ;includes trailing ' \ ' ;check for illegal characters in file name For $i = 1 To UBound($aXChars) - 1 $Pos = StringInStr($FN, $aXChars[$i], 1) If $Pos > 0 Then $BadChar = True MsgBox(16, "Illegal File Name", "Illegal character in Resultant File Name: " & "'" & $aXChars[$i] & "'" & @CRLF & @CRLF & _ "ASCII Character Number: " & Asc($aXChars[$i]) & ", Position: " & $Pos) EndIf Next If Not $BadChar Then $NewPath = $sDir & $FN & $f_Ext ;$f_Ext includes dot, ' .exe ' If FileExists($sFileFullDir) Then If FileGetSize($sFileFullDir) > 0 Then If $NewPath <> $sFileFullDir Then $Renamed = FileMove($sFileFullDir, $NewPath, 1) ;rename file If $Renamed Then $aSPath = _PathSplit($NewPath, $f_Drive, $f_Dir, $f_Name, $f_Ext) $aFileArg[$i_Index] = $FN & $f_Ext Else MsgBox(16, "FILE RENAMING ERROR", $sFileFullDir & @CRLF & @CRLF & "could not be renamed to" & @CRLF & @CRLF & $NewPath) EndIf EndIf Else MsgBox(16, "FILE SIZE IS ZERO", $sFileFullDir & @CRLF & @CRLF & "could not be renamed to" & @CRLF & @CRLF & $NewPath & @CRLF & @CRLF & _ "because " & @CRLF & @CRLF & $sFileFullDir & " current file size is zero.") EndIf Else MsgBox(16, "File Not Found", $sFileFullDir & @CRLF & @CRLF & "could not be found.") EndIf EndIf Return $BadChar EndFunc ;==>_Rename_File Func _Update_Properties_View(ByRef $aFileArg, ByRef $aInput, ByRef $aOutput, $i_Index, _ ByRef $sFileName, ByRef $sFileFullDir, ByRef $sFileOrigFileName, ByRef $sFileIntName, ByRef $sFileProductName, ByRef $sFileDescription, _ ByRef $sFileVersion, ByRef $sFileProdVersion, ByRef $sFilePrivBuild, ByRef $sFileSpecialBuild, ByRef $sFileCopyright, ByRef $sFileCompanyName, _ ByRef $sFileLegTradeMrks, ByRef $sFileComments, ByRef $sFileSize, ByRef $sFileGetCreateTime, ByRef $sFileGetModTime, ByRef $sFileGetAccessTime, _ ByRef $sFileAttribute, ByRef $sDefLangCodePage, ByRef $e_sFileName, ByRef $e_sFileFolder, ByRef $e_sFileOrigFileName, ByRef $e_sFileIntName, _ ByRef $e_sFileProductName, ByRef $e_sFileDescription, ByRef $l_sFileVersion, ByRef $l_sFileProdVersion, ByRef $l_sFilePrivBuild, ByRef $l_sFileSpecialBuild, _ ByRef $e_sFileCopyright, ByRef $e_sFileCompanyName, ByRef $e_sFileLegTradeMrks, ByRef $e_sFileComments, ByRef $l_sFileSize, ByRef $l_sFileGetCreateTime, _ ByRef $l_sFileGetModTime, ByRef $l_sFileGetAccessTime, ByRef $l_sFileAttribute, ByRef $l_sFileCount, ByRef $l_sDefLangCodeP) ;update Properties Values for newly renamed file $sFileName = $aFileArg[$i_Index] $sFileFullDir = $aFileArg[1] & "\" & $aFileArg[$i_Index] $sFileOrigFileName = StringStripWS(FileGetVersion($sFileFullDir, $FV_ORIGINALFILENAME), 3) $sFileIntName = StringStripWS(FileGetVersion($sFileFullDir, $FV_INTERNALNAME), 3) $sFileProductName = StringStripWS(FileGetVersion($sFileFullDir, $FV_PRODUCTNAME), 3) $sFileDescription = StringStripWS(FileGetVersion($sFileFullDir, $FV_FILEDESCRIPTION), 3) $sFileVersion = StringStripWS(FileGetVersion($sFileFullDir), 3) $sFileProdVersion = StringStripWS(FileGetVersion($sFileFullDir, $FV_PRODUCTVERSION), 3) $sFilePrivBuild = StringStripWS(FileGetVersion($sFileFullDir, $FV_PRIVATEBUILD), 3) $sFileSpecialBuild = StringStripWS(FileGetVersion($sFileFullDir, $FV_SPECIALBUILD), 3) $sFileCopyright = FileGetVersion($sFileFullDir, $FV_LEGALCOPYRIGHT) $sFileCompanyName = StringStripWS(FileGetVersion($sFileFullDir, $FV_COMPANYNAME), 3) $sFileLegTradeMrks = FileGetVersion($sFileFullDir, $FV_LEGALTRADEMARKS) $sFileComments = FileGetVersion($sFileFullDir, $FV_COMMENTS) $sFileSize = FileGetSize($sFileFullDir) $sFileGetCreateTime = FileGetTime($sFileFullDir, $FT_CREATED, 0) $sFileGetModTime = FileGetTime($sFileFullDir, $FT_MODIFIED, 0) $sFileGetAccessTime = FileGetTime($sFileFullDir, $FT_ACCESSED, 0) $sFileAttribute = FileGetAttrib($sFileFullDir) $sDefLangCodePage = StringStripWS(FileGetVersion($sFileFullDir, "DefaultLangCodepage"), 3) ;replace file's single letter attribute(s) with verbose list of labels For $i = 1 To $aInput[0] $sFileAttribute = StringReplace($sFileAttribute, $aInput[$i], $aOutput[$i], 0, $STR_CASESENSE) Next $sFileAttribute = StringStripWS(StringTrimRight($sFileAttribute, 2), 3) ;conversion of file's Property Values to user-meaningful display formats $sFileSize = _WinAPI_GetNumberFormat(0, $sFileSize, _WinAPI_CreateNumberFormatInfo(0, 0, 3, ' ', ',', 1)) & " bytes" $sFileGetCreateTime = _DateToMonth($sFileGetCreateTime[1]) & " " & $sFileGetCreateTime[2] & ", " & $sFileGetCreateTime[0] & " " & $sFileGetCreateTime[3] & ":" & _ $sFileGetCreateTime[4] & ":" & $sFileGetCreateTime[5] $sFileGetModTime = _DateToMonth($sFileGetModTime[1]) & " " & $sFileGetModTime[2] & ", " & $sFileGetModTime[0] & " " & $sFileGetModTime[3] & ":" & _ $sFileGetModTime[4] & ":" & $sFileGetModTime[5] $sFileGetAccessTime = _DateToMonth($sFileGetAccessTime[1]) & " " & $sFileGetAccessTime[2] & ", " & $sFileGetAccessTime[0] & " " & $sFileGetAccessTime[3] & ":" & _ $sFileGetAccessTime[4] & ":" & $sFileGetAccessTime[5] ;update $hAFVGUI value labels _GUICtrlRichEdit_SetText($e_sFileName, $sFileName) _GUICtrlRichEdit_SetText($e_sFileFolder, $aFileArg[1]) _GUICtrlRichEdit_SetText($e_sFileOrigFileName, $sFileOrigFileName) _GUICtrlRichEdit_SetText($e_sFileIntName, $sFileIntName) _GUICtrlRichEdit_SetText($e_sFileProductName, $sFileProductName) _GUICtrlRichEdit_SetText($e_sFileDescription, $sFileDescription) GUICtrlSetData($l_sFileVersion, $sFileVersion) GUICtrlSetData($l_sFileProdVersion, $sFileProdVersion) GUICtrlSetData($l_sFilePrivBuild, $sFilePrivBuild) GUICtrlSetData($l_sFileSpecialBuild, $sFileSpecialBuild) _GUICtrlRichEdit_SetText($e_sFileCopyright, $sFileCopyright) _GUICtrlRichEdit_SetText($e_sFileCompanyName, $sFileCompanyName) _GUICtrlRichEdit_SetText($e_sFileLegTradeMrks, $sFileLegTradeMrks) _GUICtrlRichEdit_SetText($e_sFileComments, $sFileComments) GUICtrlSetData($l_sFileSize, $sFileSize) GUICtrlSetData($l_sFileGetCreateTime, $sFileGetCreateTime) GUICtrlSetData($l_sFileGetModTime, $sFileGetModTime) GUICtrlSetData($l_sFileGetAccessTime, $sFileGetAccessTime) GUICtrlSetData($l_sFileAttribute, $sFileAttribute) GUICtrlSetData($l_sDefLangCodeP, $sDefLangCodePage) GUICtrlSetData($l_sFileCount, "File " & $i_Index - 1 & " of " & $aFileArg[0] - 1) EndFunc ;==>_Update_Properties_View