Results 1 to 3 of 3

Thread: moving files from multiple directories

  1. #1
    Join Date
    Nov 2006
    Location
    Heartland of america
    Beans
    36
    Distro
    Ubuntu 9.10 Karmic Koala

    moving files from multiple directories

    Ok. I have a directory tree with lots of folders. I need to gather all files of same type, say .txt, and place them in a different folder all by themselves.

    I know I can use the mv command, but it won't let me go through all the subdirectories of my folder, just the current one.

    How can I search through all subdirectories for all .txts or whatever and move them to a folder of my choosing?

  2. #2
    Join Date
    Jul 2007
    Beans
    99

    Re: moving files from multiple directories

    not sure what version you are running, but in 10.04 i tried to see if i could do what i think you are wanting to accomplish.

    for me i decided to search my home directory for any .txt files.

    i simply went to my "home" directory in nautilus and clicked on the "go" button at the top, then selected "search for files" from the drop down list. it then added a search toolbar to nautilus. i put .txt in the box and clicked search, it then brought up every text file it found in all the sub directories of my "home" directory. you can then select, copy, move, delete whatever you want.

    hopefully this helps, unless i've misunderstood what you are trying to do.

  3. #3
    Join Date
    Jan 2008
    Location
    Manchester UK
    Beans
    13,573
    Distro
    Ubuntu

    Re: moving files from multiple directories

    You need to use find

    For this example I`m going to assume that all the .txt files are located in directories and subdirectories of your Documents folder and you want to move them to a directory in your home called scripts
    Code:
    find ~/Documents -name '*.txt' -exec mv '{}' ~/scripts \;

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
  •