Skip to main content
1 of 3
terdon
  • 252.7k
  • 69
  • 481
  • 719

Don't copy the folder, only copy the contents:

## Create the target directory. The -p suppresses error messages ## if the directory already exists mkdir -p outputFolder ## Copy the contents recursively, this will not recreate the parent cp -R inputfolder/* outputfolder/ 

This way you both ensure that the target dir is created the first time the script runs and avoid the issue when running it a second time.

Both -p for mkdir and -R for cp are defined by POSIX so this should be perfectly portable.

terdon
  • 252.7k
  • 69
  • 481
  • 719