Results 1 to 2 of 2
  1. #1
    How do i extract files from folders??

    Member Since
    Apr 22, 2013
    Posts
    1
    How do i extract files from folders??
    Hi
    I have close to 1000 folders with close to 5000 files. Is there a way to extract all files without going to each folder and extracting them to a root folder individually?

    This is several days of work that I dont want to do....

    Thanks!

  2. #2
    How do i extract files from folders??
    Raz0rEdge's Avatar
    Member Since
    Jul 17, 2009
    Location
    MA
    Posts
    8,184
    Specs:
    27" i7 iMac, 24" iMac, 13" Macbook Air, iPhone 5 & 5S, iPod Nano 7th Gen, iPad 2 16GB WiFi, iPad 3
    Welcome to Mac-Forums.

    Unless you have compressed files here, what you are talking about is not extracting, but rather copying files..

    You will probably not be able to do what you want from the UI or Finder, but rather through a shell script or something..

    For example, assume you have 10 directories with 10 files (named the same to make it complicated) like this:
    .:
    one two three four five six seven eight nine ten

    ./one:
    fileOne fileTwo fileThree fileFour fileFive fileSix fileSeven fileEight fileNine fileTen

    ./two:
    fileOne fileTwo fileThree fileFour fileFive fileSix fileSeven fileEight fileNine fileTen

    ./three:
    fileOne fileTwo fileThree fileFour fileFive fileSix fileSeven fileEight fileNine fileTen

    ./four:
    fileOne fileTwo fileThree fileFour fileFive fileSix fileSeven fileEight fileNine fileTen

    ./five:
    fileOne fileTwo fileThree fileFour fileFive fileSix fileSeven fileEight fileNine fileTen

    ./six:
    fileOne fileTwo fileThree fileFour fileFive fileSix fileSeven fileEight fileNine fileTen

    ./seven:
    fileOne fileTwo fileThree fileFour fileFive fileSix fileSeven fileEight fileNine fileTen

    ./eight:
    fileOne fileTwo fileThree fileFour fileFive fileSix fileSeven fileEight fileNine fileTen

    ./nine:
    fileOne fileTwo fileThree fileFour fileFive fileSix fileSeven fileEight fileNine fileTen

    .ten:
    fileOne fileTwo fileThree fileFour fileFive fileSix fileSeven fileEight fileNine fileTen
    You first get a list of all the files with:
    Code:
    find . -type f > file.list
    Now this script will iterate over each of the files and copy them to the local (root) directory by prefixing the directory name to each file so you know where it came from. I'm only dealing with files one level deep, if you have files that are multi-directory deep, you'll have to modify the script accordingly..

    Code:
    for file in `cat file.list`; 
    do d=`echo $file | sed -e 's/\// /g'`; 
    dir=`echo $d | awk '{print $2}'`; 
    f=`echo $d | awk '{print $3}'`; 
    echo "Moving $file to $dir-$f"; 
    mv $file $dir-$f; 
    done
    You might have to not add the "mv $file $dir-$f" portion of the script and just see what the echo is going to show you to ensure that the files are being moved properly..

    Also, you might want to play around with this script in a separate test folder until you're sure it's doing what you want before running it on the real folders..
    --
    Regards
    ...Ashwin



    Be sure to read the Community Guidelines | The more information you provide, the better answers you get, remember GIGO.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. .tar files extract to where?
    By titomedia in forum OS X - Operating System
    Replies: 1
    Last Post: 07-05-2014, 09:42 AM
  2. How to extract sitx files?
    By sinitry23 in forum OS X - Apps and Games
    Replies: 5
    Last Post: 06-25-2009, 07:44 AM
  3. extract rar files?
    By ricecook in forum OS X - Operating System
    Replies: 3
    Last Post: 12-03-2007, 09:53 PM
  4. How to extract .bin files?
    By slim91 in forum Movies and Video
    Replies: 1
    Last Post: 12-28-2006, 10:18 AM
  5. dmg.gz Files: Extract to Nowhere?
    By geekboy2000 in forum Running Windows (or anything else) on your Mac
    Replies: 10
    Last Post: 04-26-2006, 09:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •