I've been trying to do this for months, but I couldn't get it to work. I'm trying to do it in bash. All files are in a linux machine, so bash I guess?
What I'd like to do: for all files in a directory rename them with following criteria:
- if the file has square brackets in the filename, delete the brackets and including numbers
[312646416198] - if the file has a year
(2018), keep that (not all have that) - if the file has brackets with a single number in it,
(1)delete the brackets and the number
create a folder based on the first part of the file name (e.g. everything leading up to the first hyphen "-", and move that file into the created folder.
So for example the following names should after some processing look like this (ideally). Somethings will be placed wrong, like when title comes before author, so the new folder would be named after the title, not the author, but I can live with that, there's only a small percentage that are named like that.
So this:
The Brotherhood of the Rose - David Morrell.epub Abbi Glines - Bad for You (2014) [9781481420761] (1).epub Kristin Hannah - The Great Alone (2018) [9781250165619].epub Stephanie Dray, Laura Kamoie - America's First Daughter - A Novel (2016) [9780062347268] (1).epub Terence Hanbury White - The Once and Future King (1987) [9780441627400] (1).epub becomes this:
The Brotherhood of the Rose The Brotherhood of the Rose - David Morrell.epub Abbi Glines Abbi Glines - Bad for You (2014).epub Kristin Hannah Kristin Hannah - The Great Alone (2018).epub Stephanie Dray, Laura Kamoie Stephanie Dray, Laura Kamoie - America's First Daughter - A Novel (2016).epub Terence Hanbury White Terence Hanbury White - The Once and Future King (1987).epub