I couldn't find a script for this so I made one, hope it's of use to someone. With simple fixing up it could be used for all sorts of things (long lists of Jpg's from holiday snaps comes to mind)
So, I have a folder with 6, 903 sound files (.wav's) and I wanted to move them all into nice and neat organized folders. The files are in sets of anywhere from 20 to 65 files, each having a prefixed pattern to identify them as belonging to the set.
For instance:
SynthRock - drumbeat01.wav
SynthRock - shakers.wav
SynthRock - piano solo.wav
HeavyMetal - rythm chords.wav
HeavyMetal - lead.wav
Trance - arp01.wav
Trance - arp02.wav
I wanted to move all the files prefixed with SynthRock into a folder of that name, all files prefixed with HeavyMetal into a folder of that name etc. etc. etc. So I'd have this:
(folder) SynthRock >
SynthRock - drumbeat01.wav
SynthRock - shakers.wav
SynthRock - piano solo.wav
(folder) HeavyMetal >
HeavyMetal - rythm chords.wav
HeavyMetal - lead.wav
(folder) Trance >
Trance - arp01.wav
Trance - arp02.wav
I could have spent a week doing this by hand, but the thought of eventual brain numbing suicide made me realise I should invest the time in writing a script. Not so easy for someone as daft at this sort of thing as me! Took quite some trial and error, but I learned a lot from my mistakes. I've not had a go at any scripting for ages, but anyway here goes:
Code: Select all
foreach($ITEM, get("SelectedItemsNames", "|") ){
$B = getpathcomponent($ITEM, "base");
$Bshort = regexreplace($B, ^(.*)( - )(.*), $1);
if (!exists("<curpath>\$Bshort")) {
new("<curpath>\$Bshort", "dir");
}
selectitems "$ITEM";
moveto "<curpath>\$Bshort", , , ;
}
It then does a simple regex find and replace to look for the pattern and to split off the filename prefix. In my case this was " - " which seperates the first part (what I wanted for the folder name) from the rest. With my files this was easy and the regex I used was straightforward. You'll need to change the pattern here to match what you have and it may not be quite so easy or forgiving.
Following this it checks to see if a folder by the required name already exists. If it does, skip it, if not create it.
Then it selects the original file again (this stumped me for ages as the focus jumped to the newly created folder. Caused me headache for half an hour til I worked it out!). Once selected the file is moved into the corresponding folder.
The loop loops, files continue to get moved and I saved myself a whole load of pain and clicking. Wonderful.
Actually, I didn't save myself anything really, Don did by creating this software. I've no idea how I could get by on a computer everyday without XY. It's incredible.
Note: I am not a good programmer, I hash things up until they work so someone will no doubt come up with something much better.
ALWAYS test on a few files you don't need (copy some?) first before use on your really important stuff.
It worked for me, did the job flawlessly and saved me a headache.
Hope it helps someone