Batch file is moving files individually and not folders.

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
tweacle
Posts: 71
Joined: 11 Apr 2018 05:38

Batch file is moving files individually and not folders.

#1 Post by tweacle » 03 Aug 2018 10:56

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 

Squashman
Expert
Posts: 4107
Joined: 23 Dec 2011 13:59

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

#2 Post by Squashman » 03 Aug 2018 11:47

Code: Select all

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

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

tweacle
Posts: 71
Joined: 11 Apr 2018 05:38

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

#3 Post by tweacle » 03 Aug 2018 13:22

Big Big thanks

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

Squashman
Expert
Posts: 4107
Joined: 23 Dec 2011 13:59

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

#4 Post by Squashman » 03 Aug 2018 13:39

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!

Post Reply