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.)
Mr.Pebbles1961 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.