I have got about 30-40 folders that have about 10-15 files each inside. I want to remove all of the files from these folders and put them in one folder so all the files are in once place - no sub folders.Anyone have an idea on how to do this? It’s a Linux box so I am not quite sure if I need to use CP or MV - I would rather use MV since I do not have the disk space to copy.
8/27/2008 2:50:43 PM
it'd be a pretty quick affair in windows...no idea about linux though
8/27/2008 2:55:38 PM
8/27/2008 3:03:12 PM
Assuming your directory looks something like:
dir0||---dir01| |---dir011||---dir02|etc
find dir0 -type f -exec mv {} /new/directory \;
8/27/2008 3:06:12 PM
8/27/2008 3:10:31 PM
^I'd like to know that too ... Windows is ridiculously underpowered compared to a unix-based OS. (Note: I am not talking about 3rd-party software packages here)
8/27/2008 3:12:54 PM
ok I am trying now -
8/27/2008 3:17:11 PM
in windows it'd just be a search for *.*folders are sorted at the top of the list so just select the files and cut and paste to their new location
8/27/2008 3:19:33 PM
Thank you - worked perfectly
8/27/2008 3:25:01 PM
in a dos batch script it would be something likebasedir=c:\base (or get this from input):parsedirfor everything in the dirif thing is dir cd dir goto parsedirif thing is file move file to basedirset currentdir=current directoryif currentdir ! basedir cd .. rmdir currentdirEssentially you go through all the files in the basedir until you find a directory. If you find a dir you switch into it and call the function again. So you recurse through the directories, move the files you find, and then once you back out of a dir you remove it. Unless you're at the basedir in which case you do nothing
8/27/2008 3:25:44 PM
8/27/2008 3:27:46 PM
^^^You're welcome.And while I see what you guys are saying to do it in Windows, I can't help but think how horrible of solutions those are versus a one line shell command [Edited on August 27, 2008 at 3:29 PM. Reason : .]
8/27/2008 3:28:53 PM
select, drag & drop is SO horriblejust remember why linux will never become a mainstream OS, it's because of "one line shell commands" that people need to know just to work the OS
8/27/2008 3:45:16 PM
or this person could just drag and drop with gnome or kde
8/27/2008 3:52:28 PM
8/27/2008 3:59:52 PM
^ the problem is not the command line stuff, that's a benefit.The problem is that there's no unified GUI, and if you don't know what gui someone has, you can tell them how to do what they want in that GUI.It's just easier to spit out a command line command that works on all the nixes.
8/27/2008 4:01:28 PM
So which method is faster when you have hundreds of subdirectories and thousands of files?Drag and drop is not it.
8/27/2008 4:12:53 PM
8/27/2008 4:25:07 PM
not to mention the OP doesn't have that many folders and filesand yeah, i'd still prefer to drag and drop
8/27/2008 4:26:16 PM
8/27/2008 4:32:37 PM