Results 1 to 6 of 6

Thread: Is it possible to strip away a folder, and leave subfolders intact?

  1. #1
    Join Date
    Apr 2007
    Location
    Kent - England.
    Beans
    145
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Is it possible to strip away a folder, and leave subfolders intact?

    I hope my question makes sense.

    I have a 32gb sd card in my car stereo, which has a folder on it named "music", in which are subfolders "A", "B", "C" etc, containing the relevant artists and albums etc.

    What I would like it to have is all of the subfolders on the root of the card, and not in a folder named "music", but preferably without transferring everything off of the card, and then back on, as I only have a slow card reader, and there is approx 25gb of data on the card itself.

    So essentially I'd just like to strip away the "music" folder, and leave the subfolders on the root of the cards, if this is at all possible.

  2. #2
    Join Date
    May 2012
    Location
    Preston, Lancs, UK
    Beans
    75
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: Is it possible to strip away a folder, and leave subfolders intact?

    just cd into the into the music folder on the card and run mv * ../

  3. #3
    Join Date
    May 2009
    Location
    Courtenay, BC, Canada
    Beans
    1,661

    Re: Is it possible to strip away a folder, and leave subfolders intact?

    Code:
    cd /path/to/card
    mv -R Music/* .
    rm -R Music

  4. #4
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    6,597
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Is it possible to strip away a folder, and leave subfolders intact?

    Hi heyho.

    It is very possible.

    Just move the content of the folder to the root level:
    Code:
    shopt -s dotglob 
    cd /path/to/music
    mv -iv * /path/to/cardroot
    If there's a file or subdirectory that has the same name as as one on the root directory, you'll be warned with a message, and it won't be moved. For example, if you have a subdirectory named music, under music itself you'll be warned with this message:
    Code:
    mv: cannot move `music' to `/path/to/cardroot/music': Directory not empty
    In this case you'll have to move it manually with another name:
    Code:
    mv -iv /path/to/music/music  /path/to/cardroot/othermusic
    To check the directory is absolutely empty run this:
    Code:
    ls -la /path/to/music
    The expected result should be something like this
    Code:
    drwxrwxr-x 2 youruser youruser 4096 Jun 10 15:27 .
    drwxrwxr-x 4 youruser youruser 4096 Jun 10 15:27 ..
    Then you can even remove music:
    Code:
    cd /path/to/cardroot
    rm -rf /path/to/music
    That would be it.

    Other considerations: Moving your music it may means that your car player might need to rescan all your music again.

    Hope it helps. Let us know how it goes.
    Regards.
    Last edited by papibe; June 10th, 2013 at 09:42 PM.

  5. #5
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,243
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Is it possible to strip away a folder, and leave subfolders intact?

    you should be able to do it via gui easily by selecting everything in music dir (ctrl+a), cutting it (ctrl+x) and pasting it in card's root dir (ctrl+v). Move operations within the partition update only filesystem info about the moved items themselves (top level subdirs/files in this case), there should be no data transfer involved. Empty music dir can be deleted aftewards
    Last edited by Vaphell; June 10th, 2013 at 09:50 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

  6. #6
    Join Date
    Apr 2007
    Location
    Kent - England.
    Beans
    145
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: Is it possible to strip away a folder, and leave subfolders intact?

    Thanks to all who have answered, I will update with the results later today once I am at home.

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
  •