Article 4ZV70 Matching text in a list of files

Matching text in a list of files

by
Entropy1024
from LinuxQuestions.org on (#4ZV70)
Using a Bash script I want to create a folder if there is more than one matching occurrence of text in a filename, then move those matching files to that folder. This is to organise TV shows into folders. ie if in the 'to sort' folder I have the following files:
Code:mr.robot.1080p.s01e01.mkv
mr.robot.1080p.s01e02.mkv
HD.dark.s02.e10.720p.mkv
HD.dark.s02.e11.720p.mkv
30.rock.s02e02.mkv
8.days.s01e01.mkvIn the example above it would like to create the following 2 folders:
Code:mr.robot.1080p.s01e
HD.dark.s02.e1Obviously in an ideal world it would truncate the folders to
Code:mr.robot
darkHowever I think I can get that part of the script working. I'm just unsure how to search for a matching set of text within the filename. In fact I would probably strip the filenames of things like 1080P, HD, sxx, exx etc before checking for a match.

Many thanks for any help.latest?d=yIl2AUoC8zA latest?i=gNvcS24RXMU:q0h598-L7nI:F7zBnMy latest?i=gNvcS24RXMU:q0h598-L7nI:V_sGLiP latest?d=qj6IDK7rITs latest?i=gNvcS24RXMU:q0h598-L7nI:gIN9vFwgNvcS24RXMU
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments