Question

I have a requirement of copying few files in to a folder. I am not sure what the folder name will be but I am sure that the folder will be ending with -Distribution.

I have written a command:

xcopy D:\config.dat D:\All_Dist\basic_dist\*-distribution\/R

But I am getting an error message as:

File creation error - The filename, directory name, or volume label syntax is incorrect.
Was it helpful?

Solution

for /d /r "D:\All_Dist\basic_dist" %%a in (*-distribution) do (
    copy "d:\config.dat" "%%~fa"
)

Search for the required folder, then copy the file into it.

OTHER TIPS

Since my directories and files are named differently from yours, I tried to match what you are trying to do and I got this to work.

xcopy low\javadeployreg.* \Users\Philip\appData\Local\temp\*-Dist /R/Y

However, if I include the last backslash after the "*-Dist" I get the same error as you but with the added information Unable to create directory - C:\Users\Philip\appData\Local\temp*-Dist so it looks like you just have to remove that last backslash.

the /Y is needed or you will get a prompt for each file you attempt to overwrite a file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top