Move all subfiles into parent folder

Hi everyone.
I have a large number of music directories with a mixture of subfolders, audio files and non-audio files. I'm trying to move all of the subfile contents of specific subdirectories named "FLAC" into the parent of each FLAC directory respectively. I want to move all subfile contents of FLAC, including the contents of any subfolders, but I do not want to move the subfolders themselves.
My structure is like so:
The monitored folder is "OC Remix".
Sometimes the structure goes down another level like so:
There is no consistency for the "CD 01" level, or whether there is a "CD 01" level subfolder, so I'm trying to account for that variable.
The goal is to move "song.flac" and any other files of any kind in that directory (like artwork.png, tracklist.txt, or Artwork directory) into the "AlbumName" directory, leaving "FLAC" (and if it exists "CD 01") where they are, but completely empty.
Below is a screenshot of my current rule that does find the correct matches, but does not move the files. I embedded a simple shell script to move the file up a single folder level, but instead the files move up as many as four directory levels. They always move to "_To Sort", which is one level above the monitored folder and (again) up to four levels above the matched file that I'm intending to target. The link also shows a screenshot of a sample album from this folder structure.
https://imgur.com/a/m96DWxk
If this were working properly, there is a second rule that will run the rules on folder contents, so my expectation is that for directories with a "CD 01", Hazel will move the files up one level into the FLAC folder on the first run, then cycle through again and move them into the "AlbumName" folder, at which point the files will no longer match the rule and will not be moved up again.
Can anyone more savvy in Hazel or shell scripting point out my mistake as I know this should be very simple. If there is an easier way to do this, I'm all for it. Right now I'm driving myself bald working on this.
EDIT: So I realized after a bit more testing and reflection that the script is being run relative the monitored folder and not relative to the matched file. The shell command to move up a single level is moving everything up a single level from the monitored folder and not from the matched file. Why is this happening and what would be the proper syntax to move up one level relative to the matched file?
I also realized that I forgot to enclose $1 in quotes and add an exit status in the script, so I updated the script as seen below for good measure, but the issue persists:
I have a large number of music directories with a mixture of subfolders, audio files and non-audio files. I'm trying to move all of the subfile contents of specific subdirectories named "FLAC" into the parent of each FLAC directory respectively. I want to move all subfile contents of FLAC, including the contents of any subfolders, but I do not want to move the subfolders themselves.
My structure is like so:
- Code: Select all
/ExternalDrive/_To Sort/OC Remix/AlbumName/FLAC/song.flac
The monitored folder is "OC Remix".
Sometimes the structure goes down another level like so:
- Code: Select all
/OC Remix/AlbumName/FLAC/CD 01/song.flac
There is no consistency for the "CD 01" level, or whether there is a "CD 01" level subfolder, so I'm trying to account for that variable.
The goal is to move "song.flac" and any other files of any kind in that directory (like artwork.png, tracklist.txt, or Artwork directory) into the "AlbumName" directory, leaving "FLAC" (and if it exists "CD 01") where they are, but completely empty.
Below is a screenshot of my current rule that does find the correct matches, but does not move the files. I embedded a simple shell script to move the file up a single folder level, but instead the files move up as many as four directory levels. They always move to "_To Sort", which is one level above the monitored folder and (again) up to four levels above the matched file that I'm intending to target. The link also shows a screenshot of a sample album from this folder structure.
https://imgur.com/a/m96DWxk
If this were working properly, there is a second rule that will run the rules on folder contents, so my expectation is that for directories with a "CD 01", Hazel will move the files up one level into the FLAC folder on the first run, then cycle through again and move them into the "AlbumName" folder, at which point the files will no longer match the rule and will not be moved up again.
Can anyone more savvy in Hazel or shell scripting point out my mistake as I know this should be very simple. If there is an easier way to do this, I'm all for it. Right now I'm driving myself bald working on this.

EDIT: So I realized after a bit more testing and reflection that the script is being run relative the monitored folder and not relative to the matched file. The shell command to move up a single level is moving everything up a single level from the monitored folder and not from the matched file. Why is this happening and what would be the proper syntax to move up one level relative to the matched file?
I also realized that I forgot to enclose $1 in quotes and add an exit status in the script, so I updated the script as seen below for good measure, but the issue persists:
mv -v "$1" ..
exit 0