You can copy the contents of a folder /source to another existing folder /dest with the command:
cp -a /source/. /dest/
The -a option is an improved recursive option, that preserves all file attributes and symlinks.
The . at end of the source path is a specific cp syntax that copies all files and folders, including hidden ones.
You can copy the contents of a folder /source to another existing folder /dest with the command:
cp -a /source/. /dest/
The -a option is an improved recursive option, that preserves all file attributes and symlinks.
The . at end of the source path is a specific cp syntax that copies all files and folders, including hidden ones.
An alternate is rsync:
rsync -a source/ destination
The advantages of rsync are:
- After the initial sync, it will then copy only the files that have changed.
- You can use it over a network, convenient for files in $HOME, especially config files.
windows - How to copy specific files from one folder to another from the command prompt - Stack Overflow
linux - Copying All Files Between Directories in Terminal (Mac) - Stack Overflow
Using terminal, how to copy paste a folder, like you would from finder? - Ask Different
How to copy all files in a folder to another folder in the terminal?
Spot the difference:
cp /home/rits/Desktop/folder1/name_of_textfile /home/rits/Desktop/folder2/
- a space after
cp - desktop will be with a D, not a d
- after that are 2 arguments: filename and destination
- if you want to copy directories you need -R as an option after
cp.
You're using cp the incorrect way, and possibly your desktop folder is called Desktop (but in fact I am on a national language version, so I cannot be sure).
Let's assume that you have these 2 folders:
- /home/rits/Desktop/folder1
- /home/rits/Desktop/folder2
Also assume that folder1 contains the file: text.txt. Now if you'd like to copy text.txt from folder1 to folder2, you'd go:
cp /home/rits/Desktop/folder1/text.txt /home/rits/Desktop/folder2
To learn more about commands, either read the manual page of that command by typing man command_name or you can search the internet, and find a vast amount of beginner information like:
- https://help.ubuntu.com/community/CommandLineResources
Try using
xcopy /d /y /s "\Your Image Folder\*.jpg" "C:\Users\%username%\Desktop\Master Image Folder\"
Also you can simply use
copy *.<extension> <other folder>
For example :
copy C:\Users\desktop\*.jpg D:\backup
will copy all files with extension .jpg from path C:\Users\desktop\ to D:\backup\
Something like:
xcopy /s "c:\source\*.jpeg" "c:\destination\"
should do the trick. Additionally, if you type xcopy /?, you should get the documentation. (you can replace .jpeg with whatever file extension you want.
The information on the page Microsoft DOS xcopy command provides considerably more information and guidance.
In the command:
cp -r dir1/* dir2/
the shell expands dir1/* and passes the result to cp. The * pattern does not match a leading ., that is it matches files which are usually visible. You can use the pattern dir1/.* to match those entries beginning with a ., but for cp there is a better way. From man cp:
If source_file designates a directory, cp copies the directory and the entire subtree connected at that point. If the source_file ends in a /, the contents of the directory are copied rather than the directory itself.
So what you are after is:
cp -r dir1/ dir2/
You can include the hidden files and folders if you replace the * (star) with a . (dot) in your command.
Try
cp -R /var/www /media/magneto Avoid the extra forward slash at the end of the path name.
Or
you can navigate to the /var directory in terminal and then try
cp -R www /media/magneto
If the magneto directory exists, you can use the following command:
cp -R /var/www /media/magneto
If it doesn't already exist you can use the following command to create it:
rsync -av /var/www/ /media/magneto
The option you're looking for is -R.
cp -R path_to_source path_to_destination/
- If
destinationdoesn't exist, it will be created. -Rmeanscopy directories recursively. You can also use-rsince it's case-insensitive.- To copy everything inside the source folder (symlinks, hidden files) without copying the source folder itself use
-aflag along with trailing/.in the source (as per@muni764's /@Anton Krug's comment):
cp -a path_to_source/. path_to_destination/
You are looking for the cp command. You need to change directories so that you are outside of the directory you are trying to copy.
If the directory you're copying is called dir1 and you want to copy it to your /home/Pictures folder:
cp -r dir1/ ~/Pictures/
Linux is case-sensitive and also needs the / after each directory to know that it isn't a file. ~ is a special character in the terminal that automatically evaluates to the current user's home directory. If you need to know what directory you are in, use the command pwd.
When you don't know how to use a Linux command, there is a manual page that you can refer to by typing:
man [insert command here]
at a terminal prompt.
Also, to auto complete long file paths when typing in the terminal, you can hit Tab after you've started typing the path and you will either be presented with choices, or it will insert the remaining part of the path.
There is an important distinction between Linux and Unix in the answer because for Linux (GNU and BusyBox) -R, -r, and --recursive are all equivalent, as mentioned in this answer. For portability, i.e. POSIX compliance, you would want to use -R because of some implementation-dependent differences with -r. It's important to read the man pages to know any idiosyncrasies that may arise (this is a good use case to show why POSIX standards are useful).
