We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › How to make a list of sound files on HD
Page Index Toggle Pages: 1
How to make a list of sound files on HD (Read 1438 times)
How to make a list of sound files on HD
Dec 12th, 2009, 1:06pm
 
Hi Everyone,

I'm working on a personal project for which i need to write a program which will search my computer's hard drive and make a big list of all the AIFF and WAV files it finds. I'd also like to be able to store their modification dates.

I've been building this in Max/MSP today and it can't really handle huge lists. So I though it might try a different platform.

Is this possible in processing?

Cheers for any pointers,

John.
Re: How to make a list of sound files on HD
Reply #1 - Dec 12th, 2009, 1:12pm
 
unix-like systems would do that in a one-line script! (cygwin would help you porting unix-like commands to windows)

you can do that with Processing (mostly using standard Java methods) but if you don't need anything else than a text list, a simple shell script would do the job.
Re: How to make a list of sound files on HD
Reply #2 - Dec 12th, 2009, 1:32pm
 
For your information, this unix command would list all Processing files in your home dir :
find ~/ -iname "*.pde" -exec ls -lrt {} \;

---

To do the same with Processing / Java, see the following link :
http://processing.org/hacks/hacks:listing-files

and the Javadoc :
http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html

You can retrieve the modification date with java.io.File lastModified() method.
Re: How to make a list of sound files on HD
Reply #3 - Dec 12th, 2009, 1:58pm
 
Ahh, thanks!

That is super useful, I'm on a mac and i can actually get the "find ~/ -iname "*.pde" part of the script to work directly in Max/MSP using the 'shell' object in Max.

Is there a way to search for file type rather than extension? - on the mac not all sound files have an extension.

Thanks again,

John.
Re: How to make a list of sound files on HD
Reply #4 - Dec 13th, 2009, 1:49am
 
You would have to search for the mime-type of the file, but I don't know how to do this.

Are you sure that the extension is not hidden? OS X sometimes hides somes extensions and show some others. Have a look in Finder preferences, maybe :
http://www.fileinfo.com/help/mac-show-extensions.html
Re: How to make a list of sound files on HD
Reply #5 - Dec 14th, 2009, 10:31am
 
Most newer files on a mac have extensions but it was common in the early days not to have an extension - at least I have some audio files from 3 or 4 years ago without any extensions at all.

Anyway your help has been really valuable, thanks antiplastik!


Re: How to make a list of sound files on HD
Reply #6 - Dec 14th, 2009, 1:05pm
 
what does the shell command 'file' say for the various types of audio file? can you use that? (file displays data about a file based on it's contents)

file *
1718192021.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 44100 Hz

16_stuck_on_repeat_fake_blood_remix.mp3: Audio file with ID3 version 2.3.0, contains: MPEG ADTS, layer III, v1, 320 kbps, 44.1 kHz, Stereo

05_morgenspaziergang.ogg: Ogg data, Vorbis audio, stereo, 44100 Hz, ~112000 bps, created by: Xiph.Org libVorbis I

candle_song_3.flac: FLAC audio bitstream data, 16 bit, stereo, 44.1 kHz, 14417760 samples

wav, mp3, ogg and flac all have 'audio' in their file output. this is on linux...

so, yes, to get a list of filenames
find dir -type f -exec file {} \; | grep -i audio | cut -d: -f1
where dir is the directory to search under
Re: How to make a list of sound files on HD
Reply #7 - Dec 14th, 2009, 1:28pm
 
Those older Mac files probably have a "file type" attribute, which is stored as HFS+ metadata (HFS+ is the Mac OS filesystem).  Back in the day, you could see those attributes using a now defunct software tool called ResEdit.  There is a command-line tool nowadays that lets you see what those attributes are, called GetFileInfo.  Mine is installed (OS 10.6.2, Snow Leopard) here:

% which GetFileInfo
/usr/bin/GetFileInfo


If you don't have this, you may need to install the Mac OS X developer tools http://developer.apple.com/technology/xcode.html (which requires a free registration and large download so you may want to try the "file" and other utilities described above first). For a particular file, you can say:

% GetFileInfo -t "fileName"

and you will get back a four-character code telling you what the old Apple-registered file type is for that file.  With a little scripting, you could use this to sift through those older files without an extension and pick out only those with a file type that indicates audio data.

On newer files, the other methods mentioned here work better.  Most new files just give a type code of "\0\0\0\0" when I try it.
Page Index Toggle Pages: 1