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.
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
linux - Copying All Files Between Directories in Terminal (Mac) - Stack Overflow
windows - How to copy specific files from one folder to another from the command prompt - Stack Overflow
Using terminal, how to copy paste a folder, like you would from finder? - Ask Different
bash - Copy files from one directory into an existing directory - Stack Overflow
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 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.
What you want is:
cp -R t1/. t2/
The dot at the end tells it to copy the contents of the current directory, not the directory itself. This method also includes hidden files and folders.
cp dir1/* dir2
Or if you have directories inside dir1 that you'd want to copy as well
cp -r dir1/* dir2
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
