Reputation: 1
I need to be able to copy a file.txt in "C:\Some Directory\" to every folder within "C:\Some Other Directory"
So far, I have come up with this code:
@echo off
setlocal EnableDelayedExpansion
Cd "C:\Some Other Directory"
for /d /r %%G in (*) do (
Copy "C:\Some Directory\file.txt" "C:\Some Other Directory\%%G"
)
However, when I run it, It returns this error for each folder:
c:\Some Other Path\Folder
0 file(s) copied
The filename, directory name, or volume label syntax is incorrect.
Any ideas?
Update
Derp, I just had to remove the /r, it was searching for files that didn't exist.
Upvotes: 0
Views: 32
Reputation: 80203
%%G
will contain the entire destination path, so "C:\Some Other Directory\%%G"
will be resolved to "C:\Some Other Directory\C:\Some Other Directory\a_subdirectory"
Simply remove the C:\Some Other Directory\
prefix.
Upvotes: 2