0

I have a list of folderpaths in a .txt. For each path i want to search all subfolders and copy each file to the same folder (without copying the folder).

I tried this, but I cannot get it to work

@echo off 
chcp 65001
SetLocal EnableDelayedExpansion
set dst_folder=C:\Users\JB4555\OneDrive - Jyske Bank\Kopier_RKM_SASDataset\Data
for /f "tokens=*" %%a in (datapaths.txt) do (
    for /r "%%a" %%b in ("*.sas7bdat") do (
        echo "%%b"
        pause
        Robocopy "%%b" "%dst_folder%"
    )
)
EndLocal

Any input?

jeb
  • 78,592
  • 17
  • 171
  • 225
Rud Faden
  • 343
  • 2
  • 17
  • The syntax usage for `ROBOCOPY` is pretty clear. **Usage :: ROBOCOPY source destination [file [file]...] [options]**. It also goes on to say that `SOURCE` is a directory and `DESTINATION` is a directory and `FILE` are the files you want to copy is a directory. – Squashman Nov 11 '21 at 14:47
  • Thats not my problem. The loops is the issue. It is not working. It is not working with copy either – Rud Faden Nov 11 '21 at 15:32
  • Prove that it is not your problem. You need to provide errors and debugging details. Just telling us it doesn't work doesn't help us solve your problem. There is nothing syntactically wrong with either of the `FOR` commands. However your syntax for `ROBOCOPY` is DEAD wrong. – Squashman Nov 11 '21 at 15:36

0 Answers0