Create inventory of external disk using Terminal

Discussion in 'Mac Programming' started by MarMorr, May 30, 2014.

  1. MarMorr macrumors newbie

    Joined:
    May 30, 2014
    #1
    I have many external hard drives (Firewire mostly) that have archived video projects and files. I need to make a text file that shows all files and their paths on each external hard disk making a different text file for each external disk. The purpose is to be able to search these text files without the external hard disks being mounted. These text files hopefully will show which external disk has the searched file and the path it takes on the disk. I have found one terminal command line but it doesn't work for me. This is it:

    ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^/]*//--/g' -e 's/^/ /' -e 's/-/|/'

    This was supposed to make the list in Terminal which could be copy/pasted into a text doc for searching but it doesn't work for me.

    Is it possible to inventory an external hard drive?
    Suggestions??
     
  2. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #2
  3. Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #3
    Look at the Terminal commands at the bottom of this page that will print folder contents to a text file on your Desktop that would be searchable. You will need to specify the path to the external Volume and run this for each drive.
     
  4. subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #4
    How many files are there in total on all disks? A text file is linear, searching it will be very slow if there is a lot of files on it, as an example my main OS X disk has 1011136 files on it. And how are you suppose to keep those text files in sync with all your disks? You will have to update them as soon as you add or remove a file.

    Have you considered using Spotlight to index your disks?
     
  5. MarMorr thread starter macrumors newbie

    Joined:
    May 30, 2014
    #5
    Got it

    That worked, thanks a million.

    Just an FYI - As a video professional I have thousands of video clips. Some are finished masters, some are raw video clips, some are just graphic's such as logos and still pictures. My goal was to search for a particular clip or graphic but not knowing which of the dozens of archive hard drives to search was daunting. This way I just search the text file for the name and it gives me the Volume and path, SWEET.

    THX
     
  6. subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #6
    If you don't have more files than that then I guess it could be manageable, but flat databases belongs in the 1960's. :)
     
  7. unplugme71 macrumors 68030

    Joined:
    May 20, 2011
    Location:
    Earth
    #7
    Guess you can delete the text file and re-run the command once you add new videos.

    Personally, I would use a database to store this data. Create a few columns: row_id, file name, file path, volume name

    Create an automator function to run when a disk is plugged in to scan the disk. If it finds a new file, it adds a new row. If a file is not found, it removes it from the DB.
     
  8. subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #8
    Yes, but when your disk has over a million files, it takes a lot of time, then add several disks.. I agree about the DB but Spotlight already uses one.
     
  9. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #9
    Spotlight usually stores its index on the indexed disk itself. This wouldn't meet the OP's requirement:
    The purpose is to be able to search these text files without the external hard disks being mounted.​
     
  10. subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #10
  11. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #11
  12. unplugme71 macrumors 68030

    Joined:
    May 20, 2011
    Location:
    Earth
    #12
    yes, but spotlight only works when the drive is attached. Using a DB with a front end to do the search will always work and be available.
     

Share This Page