I've bunch of folders in folder A
. I want to move files from all those folders to A
.
Or
I want to cut all files from child folders and paste them in parent folder.
How to do that?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityGo to your A
directory and run
find . -mindepth 2 -type f -print -exec mv {} . \;
which means "find all files in this directory and its sub-directories and execute mv with target directory . for each file found to move them to current directory.
find
you can be a little more elegant and not spawn a mv
process for each file: find A -mindepth 2 -type f -exec mv -t A \{\} +
Sep 23, 2014 at 20:09
find . -mindepth 2 -type f -print -exec mv --backup=numbered {} . \;
Well you could create a file and name it "cutme" (to create a file called cutme in the terminal type nano cutme
. To save it press CTRL+X then press ENTER.) for example and paste the following in it assuming that:
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
.
mv */* .
?mv */* .
won't move files from subfolders' subfolder.