[SOLVED]folder filter by name

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
tungle
Posts: 2
Joined: 29 Nov 2011 23:29

[SOLVED]folder filter by name

#1 Post by tungle » 29 Nov 2011 23:41

Hi,
I need loop through a list of folder that have the same prefix, say (A1, A2,...,A100) and copy my files (from a source folder) to each folder. My try:
FOR %%A IN (*A*) DO (

XCOPY sourceFolder %%A /s/e

)


It doesn't pick the folder, it picks some files with the same prefix (say Annn.zip). I want to avoid this problem too.
Hope you guys help me out, thanks.
Last edited by tungle on 01 Dec 2011 01:26, edited 1 time in total.

trebor68
Posts: 146
Joined: 01 Jul 2011 08:47

Re: folder filter by name

#2 Post by trebor68 » 30 Nov 2011 14:05

With your code you will only use files not folders.
And you use files that have the letter "A" in the name.

You will do this with folders (directories) please use this code:

Code: Select all

FOR /d %%A IN (*A*) DO (

XCOPY sourceFolder %%A /s/e

)


If you will only use folders that will beginning with the letter "A" please don't use "*A*".
Please use this: "A*"

tungle
Posts: 2
Joined: 29 Nov 2011 23:29

[SOLVED] folder filter by name

#3 Post by tungle » 01 Dec 2011 01:25

Tks trebor68, works like a champ.

Post Reply