Raspberry Pi

How to copy files between directories in Raspberry Pi OS

From the developer perspective the Raspberry pi is a best option as it is a compact size computer that does all the functions a conventional size computer does. However, it functions quite differently as compared to the Windows and macOS so this guide will explain the methods for copying files between directories in Raspberry Pi OS.

Copying files between directories in Raspberry pi OS

If you want to copy files between directories in Raspberry pi OS, then there are two following methods:

Copying files between directories in Raspberry pi OS using GUI

If you are looking for simplest method for copying the file in between Raspberry Pi directories, then there are following steps to do it:

Step 1: First open the directory of file which you want to copy by opening the file manager from the top menu bar:

Step 2: Once you have found the file directory left click on the arrow to see the folders saved in it:

Next click on the folder in which the file you want to copy is saved:

Step 3: To copy the file right click on it and select the copy option from the dropped down menu:

Step 4: Now open the directory in which you want to save the file by selecting the paste option from the right click context menu:

Your file will be copied to the desired place but you cannot copy any directory using this method as there is no option to copy in the right click menu so you can only copy the contents of any directory using the GUI.

Copying files between directories in Raspberry Pi OS using terminal

Another method that can be used to copy files within the directories of Raspberry Pi is by using its terminal so there are few commands that one needs to execute. Follow the given steps to copy files within the directories of Raspberry Pi:

Step 1: Open the terminal of the Raspberry Pi from the top menu bar:

Step 2: Now to copy a file execute the following command:

$ cp myfolder1/file.txt myfolder2/

The above command can be only used if you want to copy any file and to further elaborate the command, I have written it generically:

$ cp <source-directory>/filename  <destination-directory>/

If you want to copy the directory, then execute the following command:

$ cp -r myfolder1 myfolder2

To give a clear understanding or this command I have written it generically:

$ cp -r <source-directory> <destination-directory>

Here the cp is used to copy and the -r is for copying the files recursively

To copy all the files of a directory, execute the following command:

$ cp -r myfolder1/* myfolder2/

To further elaborate I have written the command generically:

$ cp -r <source-directory>/* <destination-directory>/

Here the cp is used to copy and the -r is for copying the files recursively and the wildcard character (asterisk) is used to copy multiple files.

Conclusion

Raspberry Pi is one of the most favorable platforms for developers as it is quite different from other operating systems. Similarly, the methods of carrying out different functions are also different so if you are looking for different ways to copy files from one directory to another in Raspberry Pi, then read this guide.

About the author

Aaliyan Javaid

I am an electrical engineer and a technical blogger. My keen interest in embedded systems has led me to write and share my knowledge about them.