Open a terminal and execute this command:
mv -v ~/Downloads/{*,.[!.]*} ~/Videos/
It will move all the files and folders from Downloads folder to Videos folder (including "hidden" files).
To move all files, but not folders:
If you are interested in moving all files (but not folders) from Downloads folder to Videos folder, use this command
find ~/Downloads/ -type f -print0 | xargs -0 mv -t ~/Videos
To move only files from the Download folders, but not from sub-folders:
If you want to move all files from the Downloads folder, but not any files within folders in the Download folder, use this command:
find ~/Downloads/ -maxdepth 1 -type f -print0 | xargs -0 mv -t ~/Videos
here, -maxdepth option specifies how deep find should try, 1 means, only the directory specified in the find command. You can try using 2, 3 also to test.
See the Ubuntu find manpage for a detailed explanation
Answer from Anwar on askubuntu.comHow do I move a file from a different directory to my current directory?
Using mv command to move a file from one folder to another one - Strange example - Unix & Linux Stack Exchange
ubuntu - Linux command to move a directory into another directory - Stack Overflow
linux - How to move (and overwrite) all files from one directory to another? - Stack Overflow
How do I move hidden files (dotfiles)?
How do I move a file without overwriting the destination?
Can I undo a `mv` command?
Videos
Open a terminal and execute this command:
mv -v ~/Downloads/{*,.[!.]*} ~/Videos/
It will move all the files and folders from Downloads folder to Videos folder (including "hidden" files).
To move all files, but not folders:
If you are interested in moving all files (but not folders) from Downloads folder to Videos folder, use this command
find ~/Downloads/ -type f -print0 | xargs -0 mv -t ~/Videos
To move only files from the Download folders, but not from sub-folders:
If you want to move all files from the Downloads folder, but not any files within folders in the Download folder, use this command:
find ~/Downloads/ -maxdepth 1 -type f -print0 | xargs -0 mv -t ~/Videos
here, -maxdepth option specifies how deep find should try, 1 means, only the directory specified in the find command. You can try using 2, 3 also to test.
See the Ubuntu find manpage for a detailed explanation
mv ~/Downloads/* ~/Videos
It will move all the files including subfolders in the directory you want to mv. If you want to cp (copy) or rm (remove) you will need the -r (recursive) option to include subfolders.
In my example I'm in the directory main/projects/project_1/turned_in/ and I want to move markdown.md from main/work/ to my current directory
mv command can move directories also.
Use cp with -r to copy content along with the folder recursively
cp -r dir1 dir2/
Run code snippetEdit code snippet Hide Results Copy to answer Expand
Then remove the folder if u want (double check if u copied all the files LOL before removing)
rm -r dir1
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.
I came here because I'm new to this subject as well. For some reason the above didn't do the trick for me. What I did to move all files from a dir to its parent dir was:
cd to/the/dir
mv * ../
mv -f source target
From the man page:
-f, --force
do not prompt before overwriting
It's just mv srcdir/* targetdir/.
If there are too many files in srcdir you might want to try something like the following approach:
cd srcdir
find -exec mv {} targetdir/ +
In contrast to \; the final + collects arguments in an xargs like manner instead of executing mv once for every file.
Remove the target database directory and move the test_db directory itself. (This will implicitly move its contents, too.)
sudo rmdir /var/lib/mysql/data/test_db
sudo mv /var/lib/mysql/test_db /var/lib/mysql/data
Generally you don't need to provide a trailing slash on directory names.
Reading your comments, if you find that you're still getting a "no such file or directory" error, it may be that your source directory, test_db has already been moved into the target test_db directory (giving you /var/lib/mysql/data/test_db/test_db/...). If this is the case then the rmdir above will also fail with a "no such file or directory" error. Fix it with this command, and then re-run the two at the top of this answer:
sudo mv /var/lib/mysql/data/test_db/test_db /var/lib/mysql
Your command:
sudo mv /var/lib/mysql/test_db/ /var/lib/mysql/data/test_db/
is for moving /var/lib/mysql/test_db/ inside /var/lib/mysql/data/test_db/, and end up with /var/lib/mysql/data/test_db/test_db/. But as /var/lib/mysql/data/test_db/ does not exist, you're getting an error.
You should run:
sudo mv /var/lib/mysql/test_db/ /var/lib/mysql/data/
to have /var/lib/mysql/test_db/ moved inside /var/lib/mysql/data/.
Hi, all.
I have about 6-7TB worth of data that I need to merge. I've been merging manually because I've lost trust in rsync due to various mishaps (I'm sure it was my fault) and data being duplicated or put in the wrong place.
I'm at a point where I pretty much have everything in 2 folders that should be pretty similar but I want to merge everything now.
My folders look like this:
Source: /mnt/myDrive/DATA
Destination: /media/user/easystore/DATA
I want to check if the files/folders in myDrive/DATA exist in easystore/DATA before moving them so I save time as the folders are 6-7TB in size.
I tried using Grsync with the following options:
-
Preserve Time
-
Verbose
-
Ignore Existing
-
Show Transfer Progress
-
Size Only
-
Protect Remote Args
-
Additional Options: --remove-source-files
I ran this job on a 1.2TB folder going from myDrive/DATA (internal SATA) to easystore/DATA (USB) and it took about 3 hours to complete. I think it did what I want as overwriting 1.2TB would take much longer than 3 hours but am looking for confirmation/a better way before I tackler the rest of the data.
Any help is greatly appreciated - thanks in advance!
The mv command doesn't have an -R flag, it moves folders recursively:
sudo mv fromPath/ toPath/
Edit
If you want a file not to be replaced, use the -i for being prompted in case a file with the same name exists.
For those trying to move folder, on Ubuntu using Putty, just use the following command:
sudo mv /fromPath/ /toPath/
for example:
sudo mv /root/folder1 /home/folder2/
"/" in the end means you are going to move folder1 inside folder2
If you don't, you will get "no such file or directory"