Skip to main content

How to Copy and Sync Directories in Linux

How to transfer folders and subdirectories (20170210)

The Dolphin file manager in Kubuntu can be used to transfer files.  However, if you try to transfer whole directories with subdirectories and the files in them, it does not always work.  When I tried this, after the computer crash, Dolphin transferred the directories, but not the files!

Better to use CLI, the Command Line Interface.  Issuing one cryptic, gargantuan command will do exactly what you want with no muss, and no fuss.

rsync
is the command you want--

A quick google search brought up rsync, a CLI command for synchronizing directories.

The general format of the command is;

rsync -avr /miscellaneous/source/directory /miscellaneous/destination/directory

Of course, you have to figure out what exactly goes into the directory pathways.

Choose your options

-avr is the options part of the command, where
 “a” means file attributes will transfer, including permissions, comments, etc.
“v” means verbose = show what’s being done
“r” means recursive = the copy command will copy all subdirectories and their subdirectories and contents.  If you want to copy only files in that particular directory, but not subdirectories and their files, leave this one out.

There are other options as well--
"z" will 'zip' or compress the files as you go

Figuring out what goes in the pathways


I copied my Pictures file from the old, damaged installation to my new Kubuntu install.

First, I used Dolphin to navigate to a sample directory to be copied.

This meant, in my case, clicking on the 227 GiB hard drive, and finding the sample directory
/home/MyName/Pictures/1899Pix

I right-clicked Properties, and got most of the path;

/media/MyName/bdae5...16e/home/MyName/Pictures

The part with the dots in the middle is a problem, because it is the enormous name of the hard disk where my pictures reside.  I need to enter the whole name of this disk in CLI to get it to work.  It may be possible to use a nickname, but nicknaming the drive is another process, so-- 

Next step;
still using Dolphin, I clicked ‘show hidden directories’ at the top, and clicked my way down into
/media/MyName/
and found the full name of the hard drive.  So my complete source path was;
/media/MyName/bdae5a2415-a6-41gbb-130-863-c4d02416e/home/MyName/Pictures

The destination directory was
/home/MyName/Pictures. 

Opening Konsole, I typed in the full command;

rsync -avr /media/MyName/bdae5a2415-a6-41gbb-130-863-c4d02416e/home/MyName/Pictures /home/MyName/Pictures

This goes all in one line with a space between the source path and the destination path.

Press [enter] and the files copy, displaying as they go...

Comments

Popular posts from this blog

Installing HR Block Tax Software in Ubuntu Linux using Codeweavers Crossover

Running HR Block 2017 Tax Software in Ubuntu Linux  Using CodeWeavers Crossover 2017 US taxes are due to be filed by midnight on April 18, 2018. It will surprise no one that a lot of people have waited to the last minute to start filing. At 9:30 PM, I got a call from a young relative who needed to do his taxes for the first time ever. He is a Linux enthusiast, and does not have a Windows or Apple/Mac computer. I thought I would try installing HR Block 2017 Tax Software on the Linux side of my laptop. 1) Obtain and install Codeweavers Crossover for Linux This software allows you to run many Windows apps in Linux-- https://www.codeweavers.com/ 2) Download the HR Block Windows tax software package. This year, its available from www.hrblock.com/2017/DELUXEWIN You will need an activation code, which should be provided when you buy the package. The default download location is /home/yourname/Downloads/ The app’s ...

How to get AAX Audiobook files into Audible Manager

How to get AAX files into Audible Manager – 20180121 My System; Lenovo ThinkPad E440 running Windows 7 64-bit running Audible Manager 5.5.0.8 My MP3 player – Sansa Fuze THE PROBLEM I can download .AAX files from my Audible account to my windows PC, but cannot get them into the Audible Manager. For several years, I have had to manually import audiobook files into the Audible Manager after downloading them from Audible. The usual process was to download the new Audiobook to the default location, C:\Users\Public\Public Documents\Audible\Downloads I would then start up the Audible Manager's army green box. Clicking [File] and selecting [Add Audio Files] in the upper right corner would take me directly to the default file location, where all of the previous downloads reside. I would then left click on the file, and click the [Import] tab at the bottom of the page to import my new AAX Audio file into Audible Manager. Once it was there, I could l...

Critter-Resistant Planter Box

“Never a horse that couldn’t be rode, Never a rider that couldn’t be throwed.” –Cowboy Proverb I had an old, neglected planter box in my yard.  It was full of weeds, and the last couple of times I have tried to plant something in it, the voles took out the roots of my plants, and the deer and raccoons took out the tops.   When we had tree cutters take down a dead cedar tree, they cut the trunk into 16 inch logs.  I had an idea about using them to revitalize the planter and discourage the critters from eating everything.  There was no guarantee that this idea would work, or will work for every critter– But, worth a try! Here’s the planter, somewhat before renovation: The borders of the old box were nearly rotted into mulch; The old box was 4 x 8 feet.  It had good soil inside it, although full of weeds and roots.    1) Strain the soil. I laid down a blue tarp and put a piece of metal hardware cloth on top of it.  I shoveled dirt from the plant...