Eu fiz cross-posting no Stackoverflow e recebi uma solução .
Observe que o script deve ser colocado no mesmo diretório da pasta de amostra e ter a estrutura da pasta de amostra como meu exemplo.
Eu coloquei uma explicação básica e desajeitada no arquivo de lote.
@echo off
setlocal enabledelayedexpansion
@echo This script will create an SQLite database of .wav or .aiff samples in the folder you select
@echo(
@echo the script must be placed in the same directory as your sample folder.
@echo(
@echo Columns will be populated based on the following file structure:
@echo(
@echo SampleFolder\Publisher\PackName\SampleCategory (i.e. Ambience)\SampleType (i.e. Rain)\Filename.wav
@echo(
set /p "fld=What is the name of your sample folder? "
> "%fld%\SampleDb.sql" (
echo BEGIN;
echo CREATE TABLE IF NOT EXISTS "Samples" ^(File TEXT NOT NULL, Publisher TEXT, Pack TEXT NOT NULL, Category TEXT, Type TEXT, Size INT^);
)
for /r "%fld%" %%A in (*.aiff *.wav) do (
set "relative_path=%%~dpA"
set "relative_path=!relative_path:%cd%=!"
if "!relative_path:~,1!" == "\" set "relative_path=!relative_path:~1!"
call :part "!relative_path!"
set "File=%%~nxA"
set "File='!File:'=''!'"
>> "%fld%\SampleDb.sql" echo INSERT OR REPLACE INTO "Samples" VALUES ^(!File!, !Publisher!, !Pack!, !Category!, !Type!, %%~zA^);
@echo !File!, !Publisher!, !Pack!, !Category!, !Type!, %%~zA
)
>> "%fld%\SampleDb.sql" echo COMMIT;
sqlite3 -cmd ".read '%fld%\SampleDb.sql'" "%fld%\SampleDb.sqlite" ""
pause
exit /b
:part
for /f "tokens=2-5 delims=\" %%A in ("%~1") do (
set "Publisher=%%~A"
if defined Publisher (
set "Publisher='!Publisher:'=''!'"
) else set "Publisher=NULL"
set "Pack=%%~B"
if defined Pack (
set "Pack='!Pack:'=''!'"
) else "Pack=''"
set "Category=%%~C"
if defined Category (
set "Category='!Category:'=''!'"
) else set "Category=NULL"
set "Type=%%~D"
if defined Type (
set "Type='!Type:'=''!'"
) else set "Type=NULL"
)
exit /b