하위 폴더를 복사하지 않고 "cp -R"을 사용하여 모든 파일을 하위 폴더에 복사하는 방법은 무엇입니까?

하위 폴더를 복사하지 않고 "cp -R"을 사용하여 모든 파일을 하위 폴더에 복사하는 방법은 무엇입니까?

이미지 크기를 조정할 수 있도록 자체 하위 폴더에 복사하려는 이미지 폴더가 있습니다.

다음과 같습니다.

$ ls
100x100                                 image1.png
image2.png                              image3.png
image4.png                              pic1.jpg

내가 겪고 있는 문제는 명령을 실행할 때 cp -R ./. 100x100기본적으로 100x100 폴더를 자체에 추가할 수 없다는 오류가 발생한다는 것입니다.

cp: 100x100/./100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/100x100/.DS_Store: name too long (not copied)

cp -R하위 폴더도 복사하지 않고 파일을 하위 폴더에 복사하는 방법은 무엇 입니까?

답변1

쉘이 다음과 같은 경우 zsh(macos를 사용하는 경우):

set -o extendedglob # best in ~/.zshrc
cp -- {^,}100x100

다음으로 확장 예정:

cp -- ^100x100 100x100

즉, 모든 파일 100x100100x100.

숨겨진 파일도 복사합니다.

cp -- ^100x100(D) 100x100

일반 파일(디렉토리, 심볼릭 링크 등)만 복사합니다.

cp -- ^100x100(D.) 100x100

답변2

사용cp ./*.* ./100x100 아니요이 옵션은 디렉터리를 자체에 복사하지 않고 -R디렉터리의 모든 파일을 하위 디렉터리에 복사합니다 .100x100

-R옵션은 모든 하위 디렉터리를 대상에 반복적으로 복사하는 데 사용되며 이러한 일이 발생하지 않도록 하려면 사용해서는 안 됩니다.

man cp이 명령의 옵션과 용도에 대한 자세한 내용은 리소스를 참조하세요.

관련 정보