ravaged1 Posted June 9, 2015 Share Posted June 9, 2015 (edited) Looking for ideasI have 2 files.xxxxxD.txt and xxxxxP.txt I need to restore them to right place, but to do that I need to know if it's *D.txt or *P.txt.They will overwrite the corresponding files. attempted to try with this but I didn't expect it would work. Any help would be appreciated.$Restore_FileName = _PathSplit($Restore_FilePath, $R_szDrive, $R_szDir, $R_szFName, $R_szExt) $NameMatch = $R_szFName & $R_szExt If $NameMatch = "*D.txt" Then MsgBox(4096, "Found D", $NameMatch) Else MsgBox(4096, "?", $NameMatch) EndIf Edited June 9, 2015 by ravaged1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 9, 2015 Moderators Share Posted June 9, 2015 ravaged1,Just the job for a RegEx:#include <File.au3> Local $R_szDrive, $R_szDir, $R_szFName, $R_szExt $Restore_FilePath = "C:\Foo\xxxxxD.txt" $Restore_FileName = _PathSplit($Restore_FilePath, $R_szDrive, $R_szDir, $R_szFName, $R_szExt) $NameMatch = $R_szFName & $R_szExt If StringRegExp($NameMatch, "^.*D\.txt$") Then MsgBox(4096, "Found D", $NameMatch) Else MsgBox(4096, "?", $NameMatch) EndIf $Restore_FilePath = "C:\Foo\xxxxxP.txt" $Restore_FileName = _PathSplit($Restore_FilePath, $R_szDrive, $R_szDir, $R_szFName, $R_szExt) $NameMatch = $R_szFName & $R_szExt If StringRegExp($NameMatch, "^.*P\.txt$") Then MsgBox(4096, "Found P", $NameMatch) Else MsgBox(4096, "?", $NameMatch) EndIfM23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ravaged1 Posted June 9, 2015 Author Share Posted June 9, 2015 ravaged1,Just the job for a RegEx:#include <File.au3> Local $R_szDrive, $R_szDir, $R_szFName, $R_szExt $Restore_FilePath = "C:\Foo\xxxxxD.txt" $Restore_FileName = _PathSplit($Restore_FilePath, $R_szDrive, $R_szDir, $R_szFName, $R_szExt) $NameMatch = $R_szFName & $R_szExt If StringRegExp($NameMatch, "^.*D\.txt$") Then MsgBox(4096, "Found D", $NameMatch) Else MsgBox(4096, "?", $NameMatch) EndIf $Restore_FilePath = "C:\Foo\xxxxxP.txt" $Restore_FileName = _PathSplit($Restore_FilePath, $R_szDrive, $R_szDir, $R_szFName, $R_szExt) $NameMatch = $R_szFName & $R_szExt If StringRegExp($NameMatch, "^.*P\.txt$") Then MsgBox(4096, "Found P", $NameMatch) Else MsgBox(4096, "?", $NameMatch) EndIfM23The Script above won't fail. If I remove a file or the D and P but I see where StringRegExp is the way to go. Thanks a lot I'll dig into it. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 9, 2015 Moderators Share Posted June 9, 2015 ravaged1,The Script above won't fail. If I remove a file or the D and PI am afraid I do not understand your comment. The script does exactly what you asked:I need to know if it's *D.txt or *P.txtSo what is it that you really want to do?M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ravaged1 Posted June 9, 2015 Author Share Posted June 9, 2015 ravaged1,I am afraid I do not understand your comment. The script does exactly what you asked:So what is it that you really want to do?M23 I just meant I gives the Found message even if the files doesn't exist.You did answer my question though, I just needed to find a function that would help me determine if a file ends with P then do stuff If D then do other stuff. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 9, 2015 Moderators Share Posted June 9, 2015 ravaged1,Fine - as long as you have what you need.Although in future when you reply, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - I know what I wrote and it just pads the thread unnecessarily.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ravaged1 Posted June 9, 2015 Author Share Posted June 9, 2015 I don't like all the extra text either, 1st time with the new forum.It's nice, clean and modern though just not idiot proof. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 9, 2015 Moderators Share Posted June 9, 2015 ravaged1,It's nice, clean and modernMost people seem to think that it is too washed-out - nice to hear a positive comment for a change.just not idiot proofGiven the number of bugs we are finding, it is not just idiots who need proofing against!M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now