Move files and folders to parent directory
Code Snippets
The following command will move all files & directories, including hidden files in the current directory to the parent directory.
For example. If you are in /home/user/test and you run this command, it will move all files and directories in /home/user/test to /home/user
- bash
- PowerShell
bash
find . -maxdepth 1 -exec mv {} .. \;
It will throw an error when it tries to move . (current directory) but this will not be an issue:
mv: cannot move `.' to `../.': Device or resource busy
Powershell
Get-ChildItem -Path . -Depth 0 | Move-Item -Destination ..
Example
Execute
bash
$ find . -maxdepth 1 -exec mv {} .. \;
mv: cannot move '.' to '../.': Device or resource busy
$ cd ..
| Before | After |
|---|---|
bash | bash |