Help Exporting List of Files to Access Database

Saint Nick

Lifer
Jan 21, 2005
17,722
6
81
Hi everyone. I'm creating a database for my own personal use at home. I wanted to export the file structure of my music directory to an ARTIST, ALBUM, and SONG table. My music folder is organized like this:

Z:\Music\<artist>\<album>\<song.ext>

So far, I have exported the following files via each their own command.

Code:
dir /b /a:d > artist.txt
Gives me all artists in a list without the path. This will be easy to insert into the ARTIST table (there is no path to parse out). Output looks like this:

Code:
10 Years
3rd Force
AFI
After the Burial
Alice in Chains
Alter Bridge
Audioslave
etc...
Next, the following command:

Code:
dir /b /s /a:d > album.txt
gives me all artists with albums. This outputs in the following format

Code:
10 Years\Division
3rd Force\Gentle Force
AFI\Decemberunderground
AFI\Sing The Sorrow
After the Burial\After the Burial - Forgiving A Future Self
After the Burial\After The Burial - In Dreams (2010)
After the Burial\Rareform
After the Burial\Rareform (Reissue)
Alice in Chains\Alice in Chains
Alice in Chains\Dirt
Alice in Chains\Facelift
Alice in Chains\Jar of Flies
Alice in Chains\MTV Unplugged
Alice in Chains\Sap
Alter Bridge\AB III
etc...
Finally, the last command:

Code:
dir *.mp3 /b /s /a:-d-h > songs.txt
gives me all songs. The /a:-d-h tells DIR to not output directories or hidden files. So, my output looks like this:

Code:
10 Years\Division\01-10_years-actions_and_motives.mp3
10 Years\Division\02-10_years-just_cant_win.mp3
10 Years\Division\03-10_years-beautiful.mp3
10 Years\Division\04-10_years-11-00_am_(daydreamer).mp3
10 Years\Division\05-10_years-dying_youth.mp3
10 Years\Division\06-10_years-russian_roulette.mp3
10 Years\Division\07-10_years-focus.mp3
10 Years\Division\08-10_years-drug_of_choice.mp3
10 Years\Division\09-10_years-picture_perfect_(in_your_eyes).mp3
10 Years\Division\10-10_years-all_your_lies.mp3
10 Years\Division\11-10_years-so_long_good-bye.mp3
10 Years\Division\12-10_years-alabama.mp3
10 Years\Division\13-10_years-proud_of_you.mp3
10 Years\Division\14 Scream At The Walls.mp3
10 Years\Division\15 Cycle Of Life.mp3
10 Years\Division\16 Patiently.mp3
etc...
My question is, how can I parse the ALBUM names out of my album.txt file, as well as the song names from my song.txt file, and then somehow tie my SONG to an ALBUM? I know I will need to write some code, and that's fine, but I was wondering if anyone had any tips to go about doing this. I plan on using VB.NET because its easy and free.
 
Last edited:

sathyan

Senior member
Sep 18, 2000
281
0
71
Do you have Excel? Open song.txt Under Data there is a Text to Columns function. Tell it to use \ as the delimiter. You end up with a spreadsheet with 3 columns:
Artist Album Song
10 Years Division 14 Scream At The Walls.mp3
 

degibson

Golden Member
Mar 21, 2008
1,389
0
0
In python:
Code:
f = open('songs.txt', 'r')
for line in f.readlines():
  tokens = line.split('\\')
  artist = tokens[0]
  album = tokens[1]
  title = tokens[2].split('.')[0]