Regular Expression for finding filenames with certain parameters but not others

First time poster. Not a programmer, but I dabble where it intersects with my work as a composer and sound designer. I apologize if this is unnecessarily detailed, but it’s the best way I can explain it.

I’ve been working on reorganizing my massive collection of music loops and sound effects (nearly 100k files), which includes using more consistent file renaming. I’ve done a lot of the work all ready using a filesearch app and a renaming app, but neither accept regular expressions. I’ve since found apps that do and I’ve been able to improve my turnaround time, but I know it can be improved further.

My current task is to find files that contain a range of strings preceded by, and followed by, a combination of spaces, as well as ones that are preceded by only a single space and are at the end of the filename, before the file extension.

Filenames I am looking for contain:

A string containing an upper or lowercase letter A-G, possibly followed by a lowercase b or # or m or an uppercase M
String is also preceeded by one space and followed by another space, but *not* by two
Also find results where string is preceded by two spaces, but followed by only one
Also find the reverse: where string is preceded by one space, but followed by two
Also find results where string is at the end of the filename (before the file extension) and preceeded by one space, but not two.

Examples:

Strings can be things like: Am, F#, EM, Db, G
Closer Kit Am 140bpm.wav  (1spaceAm1space)
EXCLUDING Closer Kit  F#  140bpm.wav (2spacesF#2spaces)
Closer Kit  EM 140bpm.wav  (2spacesEM1space)
Closer Kit Db  140bpm.wav  (1spacesDb2spaces)
Closer Kit  140bpm G.wav  (spaceGfileextension)

I started with “search for files containing the string a space, an uppercase or lowercase letters A-G possibly followed by a lowercase b or m or # or an uppercase M, and a space“:

s[A-Ga-g][b|#|m|M]s

This resulted, as I expected, in retrieving files like:

01 Brass Swell  Cm  60bpm.wav
01 Evolving Pads  Below the City Cm 60bpm-24b.wav

But also returned:

125bpm  F# Vocal Chops.wav  (2spacesF#1space)
Brass  140bpm C.wav  (spaceCfileextension)

Where it started to fall apart was when I updated it to indicate one space on either side of the desired string, but not 2:

s(?!s{2})[A-G][b|#|m](?!s{2})s

This resulted in returning files with any number of spaces on either side of the string, including one and two, as well as some with the desired string at the end, before the file extension:

07 Woodwind—Clarinet  C  60bpm.wav
128bpm  Bass Am 1.wav
85 Pad Flutter 1 Am.wav
125bpm  F# Pad.wav

I’m assuming my problem has to do with how I’m expressing the EXCLUDE part of the formula? Or am I missing the use of some /’s or ‘s? The search app will let me stack search parameters, which might be the best answer, but it only offers “match regex” and not “exclude regex”, so I’m unsure how to deal with that.

Suggestions?

(I’ve looked at the discussions suggested by the algoritm, but they don’t seem applicable.)

New contributor

Mr.Pebbles1961 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật