Linux copy files except for files in the list?

You need to copy files using file exception ignor.list
ignor.list the contents of the file

To get here
dir1 dir2 
1.mp3 1.mp3
2.mp3 2.mp3
3.mp3 5.mp3
4.mp3 7.mp3

There are still pitfalls in file names, for example (DJ KUBA-NE!TAN - Party On!.mp3 DAVE ARMSTRONG - Make Your Move (Part 2).mp3, LMFAO - Sexy & I Know It.mp3, QUINTINO-CHEAT CODES - Can't Fight It.mp3)
Good ignor list.list a small and manually edit and enter notes such species is not a problem (LMFAO\ -\ Sexy\ \&\ I\ Know\ It.mp3)

p.s. You can use any means cp, find, rsync, scripts, the main thing that performed the task
June 8th 19 at 16:49
1 answer
June 8th 19 at 16:51
works forgot to mention that the existing files are skipped and not overwritten
$pathFrom = empty($argv[1]) ? die('Source file not specified\n') : $argv[1];
$pathTo = empty($argv[2]) ? die('target path to copy is not specified\n') : $argv[2];
$ignoreList = empty($argv[3]) ? die('File not found exception\n') : $argv[3];

if (!file_exists($pathFrom) OR !file_exists($pathTo))
 die('One folder (source or destination) was not found\n');

$ignoreFiles = file_get_contents($ignoreList);
$ignoreFiles = explode(PHP_EOL, $ignoreFiles);
$ignoreFiles = array_merge($ignoreFiles, ['.', '..']);

$files = scandir($pathFrom);

foreach ($files as $file) 
 if (in_array($file, $ignoreFiles) or file_exists("{$pathTo}/{$file}")) continue;

 if (copy("{$pathFrom}/{$file}", "{$pathTo}/{$file}"))
 echo "File: {$file} has been successfully copied\n";
 echo "File: {$file} failed to move\n";
- sofia.Maggio commented on June 8th 19 at 16:54
, Spasibo - Flossie commented on June 8th 19 at 16:57

Find more questions by tags Linux