
화이트리스트에 있는 파일을 제외하고 robocopy를 사용하여 많은 수의 파일을 이동하고 싶습니다. 화이트리스트에는 서로 다른 이름의 파일이 약 150개 포함되어 있습니다. 매개변수 를 사용하여 화이트리스트의 파일 이름을 명령줄에 복사하여 붙여넣으면 /xf
robocopy가 목록을 자릅니다.
c:\test> robocopy src dest *.ext /xf exclude1.ext exclude2.ext exclude3.ext ... exclude 299.ext exclude300.ext
결과:
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows
-------------------------------------------------------------------------------
Started : Fri May 24 14:09:31 2013
Source : C:\test\src\
Dest : C:\test\dest\
Files : *.ext
Exc Files : exclude1.ext
exclude2.ext
exclude3.ext
....
....
exclude200.ext
exclude201.ext
exclu
그런 다음:
'exclude250.ext' is not recognized as an internal or external command,
operable program or batch file.
'exclude251.ext' is not recognized as an internal or external command,
operable program or batch file.
'exclude252.ext' is not recognized as an internal or external command,
operable program or batch file.
'exclude253.ext' is not recognized as an internal or external command,
operable program or batch file.
불행하게도 화이트리스트의 파일은 직접 선택한 것이므로 와일드카드로 필터링할 수 없습니다.
이 문제를 해결할 수 있는 방법이 있나요?
답변1
Windows에서는 명령줄 길이에 제한이 있습니다(2048자 정도인 것 같습니다).
구문을 가져오려면 제외 목록의 작은 하위 집합이 지정된(인수 사용 /save:filename
) 작업 파일을 생성하고, 전체 목록을 포함하도록 파일을 편집한 다음 /job:filename
인수를 사용하여 실행해야 합니다.
답변2
robocopy 작업 파일 구문은 그다지 복잡하지 않은 것으로 나타났습니다.
특정 상황에서는 다음 내용으로 robocopy 작업 파일을 생성하여 원하는 것을 얻을 수 있습니다.
/XD
exclude1.ext
exclude2.ext
exclude3.ext
....
파일에도 동일한 작업을 수행하려면 robocopy 작업 파일은 다음과 같습니다.
/XD
exclude1.ext
exclude2.ext
exclude3.ext
....
/XF
file1.ext
file2.ext
file3.ext
....
동일한 논리를 사용하여 명령줄에서 작업 파일로 다른 옵션을 이동할 수 있습니다.
답변3
/XF filename1*.ext filename2*.ext filename3*.ext 뒤에 와일드카드를 사용해 보십시오. 이는 파일 이름이 전체 구조에서 고유하다는 것을 알고 있는 경우에만 작동합니다. 이 제한 사항을 해결하기 위해 제외하려는 파일의 명명 규칙을 변경할 수 있습니다.