What I want to do
I want to move all XML files from /source/
to /target/
How I try to do it
rsync -avz --remove-source-files /source/*.xml /target/
I am using the Symfony Process / Console Component as a wrapper for rsync.
- Process Component ^5.0
- Symfony Console ^4.3
- PHP 7.2.
protected function execute(InputInterface $input, OutputInterface $output){
$process = new Process([
'rsync', '-azv', '--remove-source-files',
$input->getArgument('source-path'),
$input->getArgument('target-path')
]);
}
My Problems
Calling my command by running php bin/console command:moveFiles /source/*.xml /target/
results in:
Too many arguments, expected arguments "command" "source-path" "target-path".
It seems like the * in /source/*.xml throws off Symfony (?) and does not let it recognize the correct amount of arguments provided. Escaping the * as in rsync -avz --remove-source-files /source/\*.xml /target/
results in:
rsync: link_stat "/source/*.xml" failed: No such file or directory (2)
How can I pass the wildcard GLOB to rsync wrapped by symfony? Is there another way to achieve this using the console?