Move 'artist - album' folders to 'artist' folders
Posted: 04 Jul 2021 06:29
Hi everyone, I hope this makes sense and I apologise of it's been asked before but I can't find anything with search.
My music is sorted in folders named 'artist - album' (eg: ACDC - Back In Black). I would like to be able to select a bunch of folders and run a script that will move them to folders named after the artist portion of the folder name (eg: ACDC - Back In Black would move to a folder named ACDC).
I have this script that moves selected files to folders named after each of the files:
I was thinking I could modify it to something like this:
Will this work? And if so, what is the code I need for the "$baseName before hyphen" part? I guess it's probably going to be some kind of regex but I can't figure out what it should be.
Thanks in advance for any help.
My music is sorted in folders named 'artist - album' (eg: ACDC - Back In Black). I would like to be able to select a bunch of folders and run a script that will move them to folders named after the artist portion of the folder name (eg: ACDC - Back In Black would move to a folder named ACDC).
I have this script that moves selected files to folders named after each of the files:
Code: Select all
end(getinfo("CountSelected") < 1), "Nothing selected!";
foreach($file, get("SelectedItemsPathNames", "|"), "|") {
$baseName = getpathcomponent($file, "base");
moveto "<curpath>\$baseName", "$file", , 2;
}Code: Select all
end(getinfo("CountSelected") < 1), "Nothing selected!";
foreach($folder, get("SelectedItemsPathNames", "|"), "|") {
$baseName = getpathcomponent($folder, "base");
$artistName = $baseName before hyphen
moveto "<curpath>\$artistName", "$folder", , 2;
}Thanks in advance for any help.