This is about the twentieth time I've tried to write this post but it always becomes a behemoth... so I'm going to try and keep it short.
Basically what I want to do is push my noobie skills to the limit by writing a script that take the output from the Deluge torrent client's console, namely the path and name of a folder when a torrent is added or completes, and then creates hardlinks for all the files within the torrent, naming them based on the various parts of the existing file's name(s) and path.
The existing download paths and file names contain everything I need except a few words that will be the same for every hardlink's name (i.e. each hardlink name would have "The" added to the beginning). I'll also need to replace certain bits of the file name with snippets of text that I can define within the script (i.e. replacing "One" with "1", or "Foos.Bar" with "Foos' Bar"). The various bits of info that can be derived from the folder path and filename would need to be rearranged in order for the new hardlink's name to match Plex's naming conventions.
The one other essential thing that the script must account for is that it should only create the hardlink if it does not already exist in the destination folder. This is complicated by the fact that the torrent(s) in question have multiple version released through the course of a week, with each version adding additional files to the folder.
I can get the deluge-console to output $torrentpath/$torrentname to a file but I don't now where to go from there.
If anyone can point me in the right direction in regards to the next step I need to take or what shell tools I should be using, then I'm happy to do as much of the leg work as I need to.
[EDIT 1]
if [[ $torrentname == "Name.*.of.Torrent.1080P" ]] then ;
cd $torrentpath/$torrentname
#the follwing gives just the YYYY from a the uploader's filename.
Eyear=$"ls 01* | sed -r 's/.{6}//; s/(.{4}).*/\1/'"
[EDIT 2]
I've answered my own question for the most part but I won't post the exact solution I came up with (and it's regex's) as it all depends on my specific scenario (folder structure and the names of the torrents I download). I will give a general overview though.
In order to set the variables I want, I'm using (or should that be "playing around with"?) ls and various sed and/or awk regex commands and pipes. I've got the commands working so that they work with the different naming schemes used by both the uploaders I use, and so that I can get most of the information I need to create a name that conforms to Plex's naming schemes (the rest of the name is standard text which I can simply insert).
In order to get to the point of having a working script, I need find answers to questions that are far beyond the scope of my original question. So before I mark this thread as solved, I'll close by saying if you're in the same boat as me and you want to extract strings from both a filename and it's folder path, research sed, awk, regex, and pipes...
sed for extracting strings from filenames, and for modifying the text
awk (piped into sed) for extracting strings from folder paths