Below is a piece that I'm trying to incorporate into that piece. What I want the below to do is look at the clipboard or variable text that looks like clipboard in code below. If it contains S01 or S02 up to say S20 i.e., it should be able to create a folder with just the name part previous to the season number. If it has a season number, i.e. is a tv show file, create a folder for the show itself and then create a subdirectory with the name of the season (S1, S2 etc, no zero) (unless either or both the show name folder and/or the season name folder already exist, in which case it just goes on to the moving part) and move the whole file(s) to the directory. The moving part shouldn't be a problem. I can probably finagle it into my non-TV show hotkey.
I've found below to the be closest of the 10 or so options I found (written by Mikeyww I believe, thank you). It does remove the name part. I don't know where that part goes or if this is the best way to deal with this. If you are needing or interested in the whole thing (it's long), I can attach later.
Here is a needle/haystack piece of another way I tried just to see my thought process
haystack := "TV Show Name S01E01 Episode Name"
Needle := S01,S02,S03,S04,S05,S06,S07,S08,S09,S10,S11,S12,S13,S14,S15,S16,S17,S18,S19,S20,S21,S22,S23,S24
Clear as mud, I'm sorry. Thanks for any help in advance.
Code: Select all
clipboard := "TV Show Name S01E01 Episode Name"
clipboard := removeBeforeword(str, "S01")
clipboard := removeAfterword2(str2, "S01") ; was removeBeforeWord
; this before part works most, other than I don't know how to save the removed part to a variable to use later
removeBeforeWord(str, word) {
RegExMatch(str, "\b\Q" word "\E\b.*", m)
; MsgBox, 4164, Result, 2 Removed BEFORE word with str variable = %Clipboard%
MsgBox, 4164, Result, 2 with m Removed BEFORE word with str variable = %Clipboard%
Return m ; This works with this M result, but not the msgbox version
}
; this doesn't work, I looked at RegEx page and don't see how what is here affects even where it decides to cut forward or back so couldn't figure out what to change.
removeAfterWord2(str2, word) {
; RegExMatch(str, "\b\Q" word "\E\b.*", m)
RegExMatch(str2, "\b\Q" word "\E\b.*", m)
MsgBox, 4164, Result, 4 Removed AFTER word with str2 variable = %Clipboard%
Return m
}