file list?

topic posted Fri, October 16, 2009 - 6:15 PM by  Bass Cadet a...
Share/Save/Bookmark
Advertisement
Does anyone know how to make a file list? I have a hard drive full of thousands of mp3 & wav files that I would like to make a list of for someone, but I can't figure out how to just make a list of text names. Help.......please.......
posted by:
Bass Cadet aka Friction
SF Bay Area
Advertisement
Advertisement
  • Re: file list?

    Fri, October 16, 2009 - 6:36 PM
    Bassie,
    if i understand correctly , yeah . .just Search for all dot mp3 from the desktop using Splat + F or the Apple key + the letter f splat + f , then in Search . . type in .mp3 or .wav or .aiff . .and then when they , those sound files , are all listed in the Search window ( t h o u s a n d s - HAhHAHHahahhah ) highlight and Copy and Paste them to a Text Edit ( application) file and save that list with a name like wav091016 or music091016
    voilá
    h t h
    • Re: file list?

      Fri, October 16, 2009 - 6:45 PM
      Nope. I don't see that symbol. I'm on a laptop.
      • Re: file list?

        Fri, October 16, 2009 - 8:52 PM
        Stosher is referring to the "command" key when he uses the term "splat", but I don't think that matters because, as you discovered, copy & paste doesn't copy the names of the files (in fact, in Snow Leopard it doesn't even let me copy the results).

        However, if you're willing to venture into the Terminal this is not too hard, since UNIX has all sorts of commands for doing exactly this type of thing. For example, here's a command you could use in the Terminal that will create a file on your Desktop called "mp3.txt" that lists just the file names (i.e. without the folder name prefixed to it) of all the files that have a ".mp3" extension anywhere in or under your home folder (but not in any other users' folders, or in any system folders):

        find ~ -iname "*.mp3" -exec basename '{}' \; > ~/Desktop/mp3.txt

        If you want a separate file with a list of your .wav files, just change the "mp3" parts of the above command to "wav" in both places. If you want a single file with both types of files in it that's a little different, but not much, depending on how you want the the final list. There's also an easy way to sort the results, but I didn't want to make things too complex.

        Here's what that command above does:

        The "find" is the actual command. The "~" tells the find command to start looking in your home folder. The "-iname" tells find to look for files with names that match the pattern you'll giveit next, and tells it to ignore the case of the file names as it's looking for them. The "*.mp3" is the pattern you're looking for, which in this case is any name (that's the * part) followed by the pattern ".mp3". Note that you need to include the double quotes around the *.mp3 part. The "-exec" part tells find to run the following command on the file names it finds, and the "basename" part is that command. This is used to strip off the folder part of the results. If you leave off this stuff then the output will include the full path name of all the files, starting with "/Users/username/...". I'm assuming you don't want this, since your friend probably doesn't care what folder(s) the various files are in. The funny looking "'{}'" part (that's a single quote, a left curly brace, a right curly brace, and another single quote) is a shorthand that represents the filename the find command found that the "basename" command is supposed to trim. The "\;" part tells the "find" command that this is the end of the sub-command that was started with the "-exec" parameter. The ">" part is the standard UNIX way of taking the output of a command and saving it to a file, and the "~/Desktop/mp3.txt" part at the end is the name of the file you want the results to be saved in.

        I know this is a complex looking command, but it's not dangerous and should be relatively standard so it should work no matter what version of OS X you're running. There may also be an easy way to do this in AppleScript, but I'm not an AppleScript guy.

        Post a follow-up here if you have any questions and I'll do what I can to help.

        Good luck!

        Dana
        • Re: file list?

          Fri, October 16, 2009 - 10:50 PM
          Wow! That worked! Thank u so much! Could u recommend any good books or tutorials on learning UNIX?
          Thanx,Jesh
          • Re: file list?

            Sat, October 17, 2009 - 10:35 AM
            There are literally thousands of different books and web pages for learning UNIX. I'd start by looking for a free online tutorial that seems to fit the way you like to learn. If you prefer books, I'd suggest going to whatever large bookseller might be nearby (e.g. Barnes & Noble, etc.) and peruse the UNIX books there. Since the default user shell in Mac OS X is "bash" I'd make sure whatever you use covers that shell, since there are subtle differences. However, you can actually write shell scripts in any of the shell languages no matter what user shell you use, so don't get too hung up on any particular one (though it'll be easier to get comfortable with one first until you get the basics down, since the slight differences in syntax in some situations can be confusing if you try to take them all in at once). Also, the user aspects of most of this stuff are pretty much the same between Linux and UNIX (they're *not* the same thing) - the big differences are in System Admin areas, such as how the various system configuration and startup files work. The Mac is based on BSD Unix, by the way, and Apple has modified the standard BSD approach in a few areas, so if you get that into this stuff that's another thing to keep in mind.

            So, I'd start looking for an online tutorial, and if you want a book check them out at a store so you can see what it's like before you buy it. Personally, I prefer having lots of small examples and exercises so I can do stuff myself, since things don't stick with me unless I actually do them a few times.

            I'm glad you got your file list(s) working, and hope you find the above useful.

            Good luck!


            Dana
            • Re: file list?

              Sat, October 24, 2009 - 5:21 PM
              Hey Dana! Thank u for your help with the file list. I have one more question though. The file list I need to make is on an external hard drive, so how do I do that? When I use your code in Terminal it only pulls up what's on the main drive.
              Thanx Jesh
              • Re: file list?

                Sat, October 24, 2009 - 5:54 PM
                Yes, that command will only look in your home directory - that's what the "~" does after the "find" at the beginning of the command. You can replace that tilde character with anything you want as the starting point for the search, however. There are a couple ways to do that:

                First, you can just type the path to the external hard drive manually. For example, if the name of your external drive is "Bob", then the path to it will almost certainly be "/Volumes/Bob", so the beginning of the command you'd use would be this:

                find /Volumes/Bob ...

                If there are spaces in the name of your external drive then you need to put quotes around the name (either single or double quotes will work in this case), like this:

                find "/Volumes/Backup Drive" ...

                You can also "escape" the space characters by putting a backslash,"\", in front of them, like this, in which case you don't need the quotes:

                find /Volumes/Backup\ Drive ...

                The other thing you can do takes advantage of a feature in Mac OS X that lets you drag folders into the terminal and the Finder will insert the path of that folder. To do this, you'd type the part of the command up to the point where you'd enter the path to the external drive (including the space after the "find" keyword), and then just drag the icon for the external drive anywhere into the Terminal window. The finder will insert the full path to the drive, along with the appropriate escape characters if there happen to be spaces or other special characters in the name, and then you can finish typing the rest of the command. This is most convenient if you want to specify a folder that's nested pretty deeply in a bunch of other folders, since typing those long path names can be a bit of a pain, so I suspect it'll be easier to just type in the path as described above.

                One final tip. If you want to search for such files on your entire system no matter where they might be then just use a single slash, "/", as the starting point for the search, like this:

                find / ...

                That's the way you specify the root of the entire filesystem. Note that you may find a bunch of stuff you weren't really interested in, since there may be audio files in various system folders, but at least you'll know you searched in all possible places. It'll even search in mounted filesystems, such as your iDisk if you're connected to it, which can be very slow, so you might want to be careful with this option. By the way, you can interrupt pretty much any Termial command by hitting "control-c" (often written "^c", or "^C") if it seems like it's taking too long or doing too much. That's the standard Linux & UNIX way to interrupt the currently running terminal command and is very handy to remember.

                Does this make sense?

                Dana

Recent topics in "Mac Tech Support"

Topic Author Replies Last Post
We have moved ! St0shEr 1 December 7, 2009
. .site 'o the moment :) St0shEr 0 November 25, 2009
. . ~ R A n d o m ∞ post Happy T Day :) St0shEr 1 November 16, 2009
Airport instability issues, 5.4.2 alan 1 October 16, 2009
Network timeout error Alan 2 September 23, 2009