ANiceSunset
ANiceSunset

Reputation: 63

Batch copy files from current directory using exclude

I know i'm missing something really silly but would like some assistance. I want to create a directory and then add contents into it. The actual location as of now are not the real thing.

C:\Location has some files such as text files or docx or anything.

C:\Location\word.docx and C:\Location\text.txt

I have done

MD "C:\Location\NewName" 
XCOPY C:\Location C:\Location\NewName /EXCLUDE C:\Location\NewName

I read about exclude and I added that in to avoid the cyclic problem but it still says can not perform cyclic copy. I would like to add the text files and docx files into the NewName folder. What am I missing?

Upvotes: 0

Views: 1619

Answers (2)

ths
ths

Reputation: 2942

if you are simply copying all files from a single folder, just use

copy location\* location\newname\

since only files will be copied, the fact that the destination folder is inside the same folder is irrelevant.

Upvotes: 0

foxidrive
foxidrive

Reputation: 41234

You cannot xcopy a folder when the destination is inside that folder.
That is what is generating the cyclic copy error.

You can xcopy to another location and then move the destination folder to where you need it.

Upvotes: 1

Related Questions