D
D
Dima2020-12-16 17:27:14
cmd/bat
Dima, 2020-12-16 17:27:14

How to copy a file to a subfolder?

@echo off
for /D %%a in ("C:\Users\test\Desktop\karty\201*\01-ANIM*") do xcopy /y /d D:\VYPISY\A23457.pdf "%%a \"

201* means all folders that start with this number. Inside this folder there is a folder 01-ANIM where you need to copy the file. If you remove \01-ANIM*, it works - it will copy to all 201*. Please tell me where is the mistake

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
wisgest, 2020-12-16
@NekOdin

Inside this folder there is a folder 01-ANIM

Why then *after 01-ANIM, if there is only one such folder.
I also doubt the possibility of using *in the path, not the file name (in the particular case, the directory).
Try
for /D %%a in ("C:\Users\test\Desktop\karty\201*") do  if exist "%%a\01-ANIM\"  xcopy /y /d D:\VYPISY\A23457.pdf "%%a\01-ANIM\"

or
for /D %%a in ("C:\Users\test\Desktop\karty\201*") do  for %%b in ("%%a\01-ANIM*") do  xcopy /y /d D:\VYPISY\A23457.pdf "%%b\"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question