I am trying to fix the following problem through a batch file.
test is a parent folder, which contains further subfolders test1, test2, test3. All these subfolders test1, test2, test3 contain some .docx files and a further subfolder archive.
- Look for existing
.docxfiles in subfolderstest1,test2,test3. - Copy them to a desired folder named
destination.
The following code works fine for the first part of problem:
for /R "C:\test" %%f in (*.docx) do xcopy %%f "C:\Users\%USERNAME%\Desktop\destination\" /exclude:c:\test\not_required.txt
Now I want to move the .docx files from subfolders test1, test2, test3 to their respective subfolder archive. Till now I could only built the following code for the second part of my problem.
for /d /r "c:\test" %%a in (*) do (
if /i "%%~nxa"=="archiv" set "folderpath=%%a"
move "C:\test\test1\test1.docx" "%folderpath%"
)
As you can see I have given for source a static file move C:\test\test1\test1.docx. I am not sure how to use more variables inside loops and Unfortunately it is not working as desired. A piece of advice from some experts would be highly appreciated.
No comments:
Post a Comment