Questions tagged [copy]

To copy is to create a duplicate of an object without destroying the original. Commonly seen in text editors that will let you copy some text and paste it somewhere else.

In computing, copy is related both to the command by which a duplicate of a specified entity is made, both in terms of its definition and content, as well as the resulting duplicate itself.

In terms of abstracted use, 'copy' such as when performing a cut-copy-paste operation via a graphical user interface, is an interface metaphor based on the physical procedure used in manuscript editing to create a page layout.

11278 questions
168
votes
8 answers

C++, copy set to vector

I need to copy std::set to std::vector: std::set input; input.insert(5); input.insert(6); std::vector output; std::copy(input.begin(), input.end(), output.begin()); //Error: Vector iterator not dereferencable Where is the…
CrocodileDundee
  • 1,853
  • 3
  • 13
  • 8
167
votes
12 answers

copying all contents of folder to another folder using batch file?

I have a folder: C:\Folder1 I want to copy all the contents of Folder1 to another location, D:\Folder2 How do I do this using a batch file?
SCM
  • 2,065
  • 2
  • 14
  • 15
163
votes
4 answers

PyTorch preferred way to copy a tensor

There seems to be several ways to create a copy of a tensor in PyTorch, including y = tensor.new_tensor(x) #a y = x.clone().detach() #b y = torch.empty_like(x).copy_(x) #c y = torch.tensor(x) #d b is explicitly preferred over a and d according…
dkv
  • 6,602
  • 10
  • 34
  • 54
154
votes
2 answers

How to copy directories in OS X 10.7.3?

Hi I'm trying to copy my rails_projects directory from haseebjaved/Desktop/rails_projects to my home directory, which is haseebjaved. How can I do this via the Command Line? Also, can I see my home directory on the UI or only via the Command Line in…
hjaved
  • 1,585
  • 2
  • 10
  • 10
153
votes
10 answers

How do you copy the contents of an array to a std::vector in C++ without looping?

I have an array of values that is passed to my function from a different part of the program that I need to store for later processing. Since I don't know how many times my function will be called before it is time to process the data, I need a…
bsruth
  • 5,372
  • 6
  • 35
  • 44
152
votes
18 answers

How to copy Java Collections list

I have an ArrayList and I want to copy it exactly. I use utility classes when possible on the assumption that someone spent some time making it correct. So naturally, I end up with the Collections class which contains a copy method. Suppose I have…
Jasper Floor
  • 4,632
  • 6
  • 26
  • 21
151
votes
6 answers

Copy file with pathlib in Python

I try to copy a file with pathlib import pathlib import shutil my_file=pathlib.Path('/etc/hosts') to_file=pathlib.Path('/tmp/foo') shutil.copy(my_file, to_file) I get this exception: /home/foo_egs_d/bin/python…
guettli
  • 25,042
  • 81
  • 346
  • 663
146
votes
21 answers

How can I clone an Object (deep copy) in Dart?

Is there a Language supported way to make a full (deep) copy of an Object in Dart? If multiple options exist, what are their differences?
george koller
  • 3,721
  • 6
  • 23
  • 27
145
votes
10 answers

Why should the copy constructor accept its parameter by reference in C++?

Why must a copy constructor's parameter be passed by reference?
Jony
  • 6,694
  • 20
  • 61
  • 71
145
votes
9 answers

BASH copy all files except one

I would like to copy all files out of a dir except for one named Default.png. It seems that there are a number of ways to do this. What seems the most effective to you?
Joe Cannatti
  • 4,989
  • 5
  • 38
  • 56
143
votes
21 answers

AWS S3 copy files and folders between two buckets

I have been on the lookout for a tool to help me copy content of an AWS S3 bucket into a second AWS S3 bucket without downloading the content first to the local file system. I have tried to use the AWS S3 console copy option but that resulted in…
cnikolaou
  • 3,782
  • 4
  • 25
  • 32
143
votes
18 answers

Copy folder structure (without files) from one location to another

I want to create a clone of the structure of our multi-terabyte file server. I know that cp --parents can move a file and it's parent structure, but is there any way to copy the directory structure intact? I want to copy to a linux system and our…
r00fus
  • 2,524
  • 2
  • 16
  • 16
142
votes
11 answers

Copying a HashMap in Java

I am trying to keep a temporary container of a class that contains member : HashMap myobjectHashMap A class called myobjectsList Then I do myobjectsListA = new myobjectsList(); myobjectsListB = new myobjectsList(); then: Add some…
user691305
  • 1,560
  • 2
  • 9
  • 12
139
votes
4 answers

How do I copy data from one table to another in postgres using copy command

We use copy command to copy data of one table to a file outside database. Is it possible to copy data of one table to another table using command. If yes can anyone please share the query. Or is there any better approach like we can use pg_dump or…
Mohitd23
  • 1,439
  • 2
  • 12
  • 10
137
votes
9 answers

How do you clone a BufferedImage

I have an object which has many bufferedimages in it, I want to create a new object copying all the bufferedimages into the new object, but these new images may be altered and i don't want the original object images to be altered by altering the new…
f1wade
  • 2,877
  • 6
  • 27
  • 43