Page 1 of 1

Batch file is moving files individually and not folders.

Posted: 03 Aug 2018 10:56
by tweacle
Hi

I have the following script Ive tried to write and 90% there but it moving the files individually and not the subfolders.

Any Ideas?

Code: Select all

@echo off
set Source=C:\DOWNLOADS
set Target=C:\DOWNLOADS1
for /F %%a in ('dir  /od /b "%Source%\btp*.*"') do set Folder=%%a
copy /y "%SourcE%\%Folder%"  "%Target%"
set Source=C:\DOWNLOADS
set Target=C:\DOWNLOADS2
for /F %%a in ('dir  /od /b "%Source%\chiltern*.*"') do set Folder=%%a
copy /y "%SourcE%\%Folder%"  "%Target%"
del /q "C:\DOWNLOADS\*"
FOR /D %%p IN ("C:\DOWNLOADS\*.*") DO rmdir "%%p" /s /q
xcopy C:\DOWNLOADS2 C:\DOWNLOADS3 /E 

Re: Batch file is moving files individually and not folders.

Posted: 03 Aug 2018 11:47
by Squashman

Code: Select all

H:\>copy /?
Copies one or more files to another location.

H:\>xcopy /?
Copies files and directory trees.

Re: Batch file is moving files individually and not folders.

Posted: 03 Aug 2018 13:22
by tweacle
Big Big thanks

Thought it was something simple just couldnt get my head round it and see why

Re: Batch file is moving files individually and not folders.

Posted: 03 Aug 2018 13:39
by Squashman
tweacle wrote:
03 Aug 2018 13:22
Big Big thanks

Thought it was something simple just couldnt get my head round it and see why
Reading is fun!