Windows Move or Copy Files and subfolder’s files into 1 path, destination will not have any directories
####################################################
PRO: have all files in one folder, CON: hard to tell certain files apart
How to Copy files from 1 directory tree into 1 path, where the destination path will have just the files without any folders.
The key is to have an engine that can rewrite filenames if filenames already exist. With this type of copy/move the destination folder is bound to have many of the same file. Example: readme.txt will appear alot, so there has to be an engine that can rewrite. So far the only enginer can just add a number every time the same file appears. So if readme.txt apepars 3 times, then you will get readme.txt and readme1.txt and readme2.txt
This tool doesnt exist yet
However my KCOPY tool can do it, i might need to recompile it, when I do I will post it
Other ways,
Using 7zip to copy files from 1 folders tree to 1 path:
1. Zip up the folder with “Store” mode so that its as fast as a copy
2. Extract with 7zip, right click on archive 7zip->Extract files…
3. Select Pathmode: No Pathnames
4. Overwrite method: Auto rename existing files
6. Extract to: Whatever folder you want to extract to
7. Hit Ok
Picky on extensions (only copy certain extensions):
1. Download TreeSize and install it (note you might need pro version for this but im not sure, I have pro version – so I dont know what the free version has)
2. Right click on the folder you want as the source (The one with your files and its subfolders, that you dont wnat)
3. open with TreeSize
4. Select extension tab and then
5. select each extension you want by holding control between clicks (multi select)
6. right click on it on any of the selected/highlighted enteries and select “Show all files of selected extensions”
7. In the main list of files right click, click once with the mouse (left click), then select all with CONTROL-A, then right click on select and click CHECK, all items should be checked
8. Click on Move Checked
9a. Move checked into a folder if you wanted a “move”.
9b. If you want a copy (and keep the files were they are origianlly as well): then select “Move checked files to Zip file” – it wont move the files into zip, it will just make a zip file and leave originals alone, so dont worry about it saying “move to zip”, Then continue from step 2 including step 2 in above section “Using 7zip to copy files from 1 folders tree to 1 path”
Here is C# sharp code that will do the same
#############################################
CITATION: http://stackoverflow.com/questions/17469235/move-all-files-and-subdirectories-from-a-folder-to-another-subdirectory-of-the-s
public static void CopyDir(string sourceFolder, string destFolder) { if (!Directory.Exists(destFolder)) Directory.CreateDirectory(destFolder); // Get Files & Copy string[] files = Directory.GetFiles(sourceFolder); foreach (string file in files) { string name = Path.GetFileName(file); // ADD Unique File Name Check to Below!!!! string dest = Path.Combine(destFolder, name); File.Copy(file, dest); } // Get dirs recursively and copy files string[] folders = Directory.GetDirectories(sourceFolder); foreach (string folder in folders) { if (folder != destFolder) { string name = Path.GetFileName(folder); string dest = Path.Combine(destFolder, name); CopyDir(folder, dest); } } }
My KCOPY add did this, plus more
#################################
Imagine this file structure
C:\Users\ C:\Users\Movies\EndersGames\movie1.avi C:\Users\Movies\EndersGames\movie2.avi C:\Users\Movies\HungerGames\movie1.avi C:\Users\Movies\HungerGames\movie2.avi C:\Users\Pics\EndersGames\movie1.pic C:\Users\Pics\EndersGames\movie2.pic C:\Users\Pics\HungerGames\Part1\movie1.pic C:\Users\Pics\HungerGames\Part2\movie2.pic
If they are all copied to 1 path (which KCOPY and above algorithms can do):
C:\Destination\movie1.avi C:\Destination\movie1-1.avi C:\Destination\movie2.avi C:\Destination\movie2-1.avi C:\Destination\movie1.pic C:\Destination\movie1-1.pic C:\Destination\movie2.pic C:\Destination\movie2-1.pic
Note: here we have a result of files that all had the same name, so its hard to tell them apart
The other algorithm can grab 1 folder with the file name, to have something like this (again KCOPY can do this):
C:\Destination\EndersGame\movie1.avi C:\Destination\EndersGame\movie2.avi C:\Destination\EndersGame\movie1.pic C:\Destination\EndersGame\movie2.pic C:\Destination\HungerGames\movie1.avi C:\Destination\HungerGames\movie2.avi C:\Destination\HungerGames\movie1.pic C:\Destination\HungerGames\movie2.pic C:\Destination\Part1\movie1.pic C:\Destination\Part2\movie2.pic
Note that this one makes more sense except we have part1 and part2 where we dont know what the files belong to.
Linux move files and subfolders files into 1 path, destination will not have any directories
####################################################
Citation: http://stackoverflow.com/questions/19880246/move-only-files-recursively-from-multiple-directories-into-one-directory-with-mv
MISSION: Move only files recursively from multiple directories into one directory with mv
IF you want to move certain extensions like that:
# find /path/to/photos -iname '*.jpg' -o -iname '*.png' -type f -exec mv -nv -t '/path/to/master' -- {} +
If you don’t want to filter by extension, and just move everything (i.e., all the files):
# find /path/to/photos -type f -exec mv -nv -t '/path/to/master' -- {} +
The -n option so as to not overwrite existing files (optional if you don’t care) and -v option so thatmv shows what it’s doing (very optional).
Extra notes:
* The directory /path/to/master must already exist (it will not be created by this command).
* Make sure the directory /path/to/master is not in /path/to/photos. It would make the thing awkward!
———————–
MISSION: Shell script to move all files from subfolders to parent folder
# find -mindepth 2 -type f -print -exec mv {} . \;
Or also:
# find * -type f -print -not -type d -and -not -regex 'cutme' -exec mv {} .. \;
Note the name cutme inside the line. It should be the same as the script you will run.
After creating the file and pasting the above line, run the following in the same folder as the script:
chmod +x cutme. This will give your new file the “Executable” flag so you can execute it like this:./cutme.
Extra Notes:
1. You want to do this recursively (In subfolders and subfolders of those subfolders)
2. You want to skip moving the script file
3. You have permissions to move the files in that folder
4. Files may or may not include spaces in their names
Thank you for posting such a great blog! It contains wonderful and helpful posts. Keep up the good work. Thank you for this wonderful Blog! Check out the way to fix Error Code 0123. Lean how you can fix it at your own or feel free to call our experts on our toll-free numbers or visit our website to know more!