LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Transfer files and omit duplicates? (https://www.linuxquestions.org/questions/linux-newbie-8/transfer-files-and-omit-duplicates-4175517314/)

Cocolate 09-03-2014 06:41 PM

Transfer files and omit duplicates?
 
Is the command to copy files over from my USB to my Music folder without copying duplicates of the same files:

Code:

cp -u /home/<user>/<device> /media/<user>/Music
I am copying music FROM usb TO music folder.

?

...

UPDATE: no that is not the command because here is my error:

Code:

cp: cannot stat ‘/home/cocolate/PENDRIVE’: No such file or directory
...

Did not work

Code:

cp -u /media/cocolate/PENDRIVE /home/cocolate/Music
Error

Code:

cp: omitting directory ‘/media/cocolate/PENDRIVE’

solarisguy 09-03-2014 06:44 PM

Try the following:

Code:

cp -uvn /home/<user>/<device> /media/<user>/Music

Cocolate 09-03-2014 06:56 PM

Quote:

Originally Posted by solarisguy (Post 5232031)
Try the following:

cp -uvn /home/<user>/<device> /media/<user>/Music

Really appreciate the quick reply solarisguy. This is my error:

Code:

cp: cannot stat ‘/home/cocolate/PENDRIVE’: No such file or directory
PENDRIVE is located at /media/cocolate

Im getting error for every way I tried that */PENDRIVE is no such file or directory.

PENDRIVE is the name of my <device>

(Name of <device> is 100% for sure PENDRIVE)

Cocolate 09-03-2014 07:12 PM

I ran the command as sudo and I got this error

cp: omitting directory ‘/media/cocolate/PENDRIVE’

This is the command I used

Code:

sudo cp -uvn /media/cocolate/PENDRIVE /home/cocolate/Music
What is my error?

Cocolate 09-03-2014 07:15 PM

I added -r

now I am seeing lots and lots of text scroll down amidst various titles of my music..

Cocolate 09-03-2014 07:19 PM

Heres a sample of the string scrolling down. I had a folder inside the USB. I have read that is why I could not copy, but it looks like it isnt copying to my music folder?

Code:

‘/media/cocolate/PENDRIVE/Downloads/Beats by sally bobo - smile.mp3’ -> ‘/home/cocolate/Music/PENDRIVE/Downloads/Beats by sally bobo - smile.mp3’

Its not copying to music is it? Its copying back to the folder its from originally, no?

Code:

-> '/home/cocolate/Music/PENDRIVE/Downloads/*
?

I ran this command

Code:

sudo cp -uvnr /media/cocolate/PENDRIVE /home/cocolate/Music
Please Help!

Cocolate 09-03-2014 07:29 PM

Ya that was not it was not copying anything. PLEEEASE HEEEELP

keefaz 09-03-2014 07:30 PM

Code:

cp -uvn /media/cocolate/PENDRIVE/*.mp3 /home/cocolate/Music
Or replace *.mp3 by * if there are other file format you want to copy
(no need to sudo if you have access to /media/cocolate/PENDRIVE as normal user)

solarisguy 09-03-2014 07:39 PM

Let's try this using rsync:

Code:

rsync -rv --progress --ignore-existing /media/cocolate/PENDRIVE/*.mp3 /home/cocolate/Music

Cocolate 09-03-2014 07:44 PM

Quote:

Originally Posted by solarisguy (Post 5232063)
Let's try this using rsync:

Code:

rsync -rv --progress --ignore-existing /media/cocolate/PENDRIVE/*.mp3 /home/cocolate/Music

Thanks, thats looking more like it. Please excuse that I had reposted this thread if you see it again.

Does it make a difference that I have folders within the folder within a folder copying from the PENDRIVE?

Here is a string that is copying:

Code:

Spirit - Moving Target (Juju RMX).mp3
    8128128 100%    6.90MB/s    0:00:01 (xfer#130, to-check=222/555)

Thats looking pretty good to me but I dont see FROM where TO where the files are they being copied?

ALSO SOME OF MY MUSIC ARE IN WAV FILES.......?

Cocolate 09-03-2014 07:50 PM

OK what that did was copy everything from the PENDRIVE folder to the Music folder but it did not copy any of the folders within the folder of the PENDRIVE (I have 3 folders within folders). So I updated the command to include the name of those folders in the path.

Nothing copied twice. That was success and the files saved to music. Thanks Thanks Thanks!

What about WAV files most likely I will just do it again and replace *.mp3 > *.WAV

Awesome

solarisguy 09-03-2014 09:23 PM

That should work for wav files as well. Be mindful that case does matter if your filesystem is case sensitive.

Your USB drive is likely FAT32, whereas your Linux system is more likely ext3 or ext4. FAT32 is not case sensitive where all ext filesystems are case sensitive.

Cocolate 09-04-2014 04:19 AM

Yes thank you so much you made my day much easier and solved my problem. Truly appreciate everything.

solarisguy 09-04-2014 05:14 AM

Glad it worked. rsync is your friend, for local and network transfers. Remember to use the -z flag for network transfers to compress and save bandwidth, at the expense of a bit of CPU time.


All times are GMT -5. The time now is 11:11 PM.