Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Extract here makes subfolder. DO NOT WANT

  1. #1
    Join Date
    Oct 2013
    Beans
    6

    Extract here makes subfolder. DO NOT WANT

    Someone please help me. I have 300 archives that I need to extract. The files inside are loose files and the archiver should be extracting them loose.
    Instead it extracts them into a subfolder. It's a miracle I haven't started crying yet. Please help.

    To elaborate, I am selecting all the files, right clicking and pressing "extract here." When I do that, it extracts the files into subfolder rather than directley into the folder I want them in.
    Last edited by edward-holystone; October 17th, 2013 at 03:03 AM.

  2. #2
    Join Date
    Aug 2009
    Location
    Makati City, Philippines
    Beans
    2,269
    Distro
    Xubuntu 16.04 Xenial Xerus

    Re: Extract here makes subfolder. DO NOT WANT

    hmm... try a script to extract each folder.
    Are your archives sequential in names? that would be better. I assume you have the following names
    sample directory structure:
    Code:
    nerdtron@node175:~/main_folder$ ls
    archive10.tgz  archive2.tgz  archive4.tgz  archive6.tgz  archive8.tgz
    archive1.tgz   archive3.tgz  archive5.tgz  archive7.tgz  archive9.tgz
    extract.sh
    We want to extract all those archives to main folder and not create any subfolders right?
    Code:
     cd /path/to/the/archives
    nano extract.sh
    Paste the following, and then save and exit the editor.
    Code:
    #!/bin/bash
    for archive in  *.tgz                  ##list all archives for loop
    do
    tar -zxvf "$archive"                   ##extract the archive
    dirname="${archive%%.*}"         ##get the name of the created subfolder
      mv  "$dirname"/* .                  ##move all contents of the subfolder up to the current directory
    done
    Run the script.
    Code:
    bash extract.sh
    After extraction, there will still be subfolders but they won't contain any file cause you already moved them on the script.
    Last edited by nerdtron; October 17th, 2013 at 05:19 AM.

  3. #3
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Extract here makes subfolder. DO NOT WANT

    sounds like a non issue.

    1. extract here with subfolders
    2. mv /dir/*/* -t /dir
    3. delete empty subdirs
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  4. #4
    Join Date
    Oct 2013
    Beans
    6

    Re: Extract here makes subfolder. DO NOT WANT

    I'm not exactly certain what you're telling me to do. These are all the archives, I want to extract the loose files inside to a folder named "songs" located at /home/edward/downloads/songs. Yes this is Ubuntu, it just looks different because I mess around with it a lot.






  5. #5
    Join Date
    Dec 2012
    Location
    USA
    Beans
    185
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Extract here makes subfolder. DO NOT WANT

    Give PeaZip a try...
    http://peazip.sourceforge.net/peazip-linux.html

    You can Download the portable version so you don't even have to install it to try it out.

  6. #6
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Extract here makes subfolder. DO NOT WANT

    i am telling you should extract the files either way because gathering them in one place is a rather trivial task
    just give correct paths/dir names so you can get your short terminal command that will do it in 1 second.

    it will be along the lines of
    Code:
    mv -t . ./*/*
    Last edited by Vaphell; October 17th, 2013 at 12:32 PM.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  7. #7
    Join Date
    Oct 2013
    Beans
    6

    Re: Extract here makes subfolder. DO NOT WANT

    What am I supposed to write in place of the periods and asterisks?
    Sorry if I'm being difficult, but this makes no sense to me:
    mv -t . ./*/*

  8. #8
    Join Date
    Jul 2007
    Location
    UK
    Beans
    17,059
    Distro
    Ubuntu Development Release

    Re: Extract here makes subfolder. DO NOT WANT

    Found this

    Code:
    for i in *.tar.gz; do tar xvzf $i -C path/to/output/directory; done
    from here http://stackoverflow.com/questions/5...-new-directory

    I would move a couple of archives to a test directory and try it out first.

  9. #9
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Extract here makes subfolder. DO NOT WANT

    Quote Originally Posted by edward-holystone View Post
    What am I supposed to write in place of the periods and asterisks?
    Sorry if I'm being difficult, but this makes no sense to me:
    mv -t . ./*/*
    . is current dir * matches anything
    post your directories so you get a ready to use command

    either way looking at the screenshots
    ctrl+alt+t to open terminal

    Code:
    cd ~/Downloads/*Beatmap*100
    enter your_home_dir/Downloads/<something>Beatmap<something>100, if the name is unique and matching, the shell should resolve it despite * wildcards. Had to use wildcards because the full name is not visible in the screenshots

    Code:
    mv -t . ./*/*
    move all files from subdirs ( ./*/* = current dir/subdirs with any name (all)/everything with any name to a target dir . (current)

    Code:
    cd ../*Beatmap*200
    go up 1 level (Downloads, ..=parent dir) and down to <something>Beatmap<something>200

    Code:
    mv -t . ./*/*
    again move anything from subdirs to the top/current directory

    Code:
    cd ../*Beatmap*300
    enter parent_dir/<something>Beatmap<something>300

    Code:
    mv -t . ./*/*
    move stuff



    this should move all the files from the extraction dirs to their respective master dir
    extract one rar and check if the relevant pair of commands works
    you can copy paste these commands one by one by highlighting here and middleclicking in terminal to paste or with ctrl+c/ctrl+shift+v
    Last edited by Vaphell; October 17th, 2013 at 03:52 PM.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  10. #10
    Join Date
    Oct 2013
    Beans
    6

    Re: Extract here makes subfolder. DO NOT WANT

    OK I give up with.

    These three folders contain the subfolders inside of which the loose files are located:
    /home/edward/Documents/Beatmap1
    /home/edward/Documents/Beatmap2
    /home/edward/Documents/Beatmap3

    I want to move the loose files inside the subfolders into this folder:
    /home/edward/Documents/Songs

    The subfolders are called "Beatmap Pack #001" All the way to "Beatmap Pack #300"
    The loose files in each subfolder have completley random names, starting with different numbers, letters and symbols.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

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