Move Subfolder Contents SSH
January 11, 2025 · AI Conversations
### Steps:
1. **Connect to your server via SSH**:
Open your terminal and connect to your server using:
ssh user@your-server-ip
2. **Navigate to the parent directory**:
Move to the directory containing the subfolder:
cd /path/to/parent-folder
3. **Move the contents of the subfolder**:
Use the `mv` command to move all contents of the subfolder (files and directories) to the parent folder:
mv subfolder/* .
4. **(Optional) Remove the empty subfolder**:
If you no longer need the subfolder, you can delete it:
rmdir subfolder
### Notes:
– The `*` wildcard moves all files and directories inside `subfolder` but does not move hidden files (those starting with a dot `.`).
– To include hidden files, use:
mv subfolder/* subfolder/.* .
**Important:** Be cautious with `mv subfolder/.*` as it might move `.` (current directory) or `..` (parent directory). To avoid this, use:
mv subfolder/{*,.*} . 2>/dev/null
5. **Verify the result**:
List the contents of the parent folder to ensure everything has been moved:
ls -la