Rah
Rah

Reputation: 11

Iterating through a folder using batch script

I have a folder containing 1000+ xml files. I need to modify these xml files, for which I am using xslt.

Now the problem that I am facing is that I want to use batch script to do this modification recursively for all the xml files in the folder, rather than doing it manually. How can I do it using batch script?

It would be helpful if anybody could tell me how can I read all the xml files present in a folder and copy them to another folder with the same name.

Upvotes: 1

Views: 2953

Answers (3)

PA.
PA.

Reputation: 29369

read this

HELP XCOPY,

and this

HELP FOR.

and try this

XCOPY \source\*.xml \destination /S

and try this

FOR %a IN (\source\*.xml) DO echo %a

and now read

HELP CALL

and read

HELP SET

and try this

FOR %a in (\source\*.xml) DO CALL youraction %~na

and by the time you understand what happened you are ready to achieve your goal.

Upvotes: 0

Rubens Farias
Rubens Farias

Reputation: 57996

Transformation:

for /r c:\your_root_folder\ %f in (*.xml) do your_transform_command %f

Copy:

copy *.xml c:\your_target_folder\.

Upvotes: 6

KLE
KLE

Reputation: 24169

Assuming you are using DOS batch ...

A simple copy operation will work:

prompt> copy *.xml destinationDir

To loop and process files individually, we use:

for %%R in (*) do (
  ...
)

Upvotes: 0

Related Questions