OS: aix shell: bsh
Hi, ppl
I have two types of files, one type ends with .pdf.marker and the other ends with .pdf
There should be always a pair with the same name (only the extensions are different).
When I move a .pdf.marker file I must also move its corresponding .pdf file.
I tried something like this:
find ${INPUT_LOCATION}/ -name "*.pdf.marker" | xargs -I file mv file ${OUTPUT_LOCATION}/. mv $(basename file .marker) ${OUTPUT_LOCATION}/.
Then I read this: xargs with multiple commands as argument and tried something like this:
find ${INPUT_LOCATION}/ -name "*.pdf.marker" | xargs -I file {mv file ${OUTPUT_LOCATION}/.; mv $(basename file .marker) ${OUTPUT_LOCATION}/.;}
but it still didnt work.
I just need to execute 2 commands after xargs.
EDIT
Following the proposed answers I got i tried to put just 2 parameters into one move command instead of two separate move commands following xargs.
find ${INPUT_LOCATION}/ -name "*.pdf.marker" | xargs -I file mv file $(basename file .marker) ${OUTPUT_LOCATION}/.
But now, the .pdf.marker is moved first, then when I try to remove the .marker from the filename to get the .pdf filename i get a warning no such file or directory.
Is there another way to get .pdf filename string?
SOLUTION
find ${INPUT_LOCATION} -name '*.pdf.marker' -exec sh -c 'mv $0 `dirname $0`/`basename $0 .marker` $1' {} ${OUTPUT_LOCATION} \;
Moved 200 000 files in cca. 25 min. without problems.
Thanks everyone who participated with their answers and a big thanks goes to you Nahuel Fouilleul!