UCS Category Prefix Batch Script
2022-06-13
As a follow-up to my previous post on batch scripts here's another useful batch script, this time for prefixing UCS categories to file names.
The Problem
When UCS was announced a few years ago I realised that it was a large improvement on the conventions that I had previously set-up for my sound library. Unfortunately it also meant I'd need to convert quite a large number of files to the new standard. I downloaded the empty UCS folder structure and set about moving my audio files into the relevant categories and renaming them to match the requirements.
Existing bulk rename tools worked pretty effectively here but when it came to adding newly created samples into the folders I wanted a faster method by which I could prefix the correct UCS category without having to fire-up any additional software, nor did I want to have to locate the new files within a folder that needed processing - I just wanted to hit a switch and have them renamed.
The Solution
The solution I came-up with is not perfect but it's still very useful. It's a batch script which checks all the .wav files in its folder and any that don't yet have the UCS prefix get it added to them. The script needs to be copied into the UCS folder you're working in and the edited to set the correct prefix. Once that's done you just execute it and it'll do it's thing. It can then be left in the folder for future use. This way your folders will gradually populate with these scripts, ready for the next time you need them.
🎬 An animated gif of the script running in a windows folder.
Copy and paste the following code block into a text file and give it the .bat file extension. You need to copy it to the folder you're working in and then change the 'prefix=### text' to the relevant category (in the example below it's set to 'ANMLcat_'):
@echo off
setlocal
set "prefix=ANMLWcat_"
set "mask=*.wav"
for /f "eol=: delims=" %%F in ('dir /b "%mask%" ^| findstr /vibc:"%prefix%"')
do ren "%%F" "%prefix%%%F"
I imagine there's possibly a way to create a look-up table which checks the parent folder name and sets the prefix dynamically, removing the need to manually edit the scripts, but for now this will do me just fine.
I'm always keen to hear people's own processes so please get in touch if you found this useful or have any batch scripts you want to share with me