Home » Questions » Computers [ Ask a new question ]

How do I move files and directories to the parent folder in Linux?

How do I move files and directories to the parent folder in Linux?

In Linux (Ubuntu), how do you move all the files and directories to the parent directory?

Asked by: Guest | Views: 485
Total answers/comments: 6
bert [Entry]

"find . -maxdepth 1 -exec mv {} .. \;

this will move hidden files as well.

You will get the message:

mv: cannot move `.' to `../.': Device or resource busy

when it tries to move . (current directory) but that won't cause any harm."
bert [Entry]

"Type this in the shell:

mv *.* ..

That moves ALL the files one level up.

The character * is a wildcard. So *.deb will move all the .deb files, and Zeitgeist.* will move Zeitgeist.avi and Zeitgeist.srt one folder up, since, of course, .. indicates the parent directory.

To move everything including folders, etc, just use * instead of *.*"
bert [Entry]

"Assuming all your hidden files begin with dot followed by a letter or a number (which they should), you could use

mv * .[A-Za-z0-9]* ..

The .[A-Za-z0-9]* part is to make sure you don't try to move . or .. along, which would fail."
"Assuming all your hidden files begin with dot followed by a letter or a number (which they should), you could use

mv * .[A-Za-z0-9]* ..

The .[A-Za-z0-9]* part is to make sure you don't try to move . or .. along, which would fail."
bert [Entry]

"A method which causes no errors and works every time:

ls -1A . | while read -r file
do
mv ""./${file}"" ..
done"
bert [Entry]

"find . -maxdepth 2 -type f -exec mv {} .. \;

I used a variation of above to move all the files from subfolders into the parent.

I'd got data in folders by year, but found by using metadata I could have them all in the same folder which made it easier to manage.

eg.

/data/2001/file_1
/data/2002/file_2
/data/2003/file_3"
Lweska [Entry]

atorvastatin ca <a href="https://lipiws.top/">atorvastatin 10mg sale</a> order lipitor 80mg online cheap