title: In spring batch how can we move the processed files to another folder, I am using MultiResourceItemReader and chunk processing
body: <p>In Spring batch application how can we move files from BatchFileDir folder to a destination folder as each file gets processed. There would be a bunch of files in BatchFileDir folder so I am using MultiResourceItemReader. I am also following the chunk based processing.</p>
  <p>I have all batch files as :</p>
  <pre><code>    @Value(&quot;BatchFileDir/batchFile_*.csv&quot;)
      private Resource[] allBatchFiles;
  </code></pre>
  <p>The Item reader is:</p>
  <pre><code>    @Bean
      public MultiResourceItemReader&lt;MyServiceRequest&gt; multiResourceItemReader() {
      MultiResourceItemReader&lt;MyServiceRequest&gt; resourceItemReader = new 
      MultiResourceItemReader&lt;MyServiceRequest&gt;();
      resourceItemReader.setResources(allBatchFiles);
      FlatFileItemReader&lt;Record&gt; reader = new FlatFileItemReader&lt;&gt;();
      DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
      String[] tokens = {&quot;id&quot;, &quot;name&quot;, &quot;author&quot;, &quot;subject&quot;};
      tokenizer.setNames(tokens);
      DefaultLineMapper&lt; MyServiceRequest&gt; lineMapper = new DefaultLineMapper&lt;&gt;();
      lineMapper.setLineTokenizer(tokenizer);
      lineMapper.setFieldSetMapper(new RecordFieldSetMapper());
      reader.setLinesToSkip(1);
      reader.setLineMapper(lineMapper);
      resourceItemReader.setDelegate(reader);
      return resourceItemReader;
  }
  </code></pre>
  <p>and the Item processor is :</p>
  <pre><code>    @Bean
      public ItemProcessor&lt; MyServiceRequest, MyServiceResponse&gt; itemProcessor() {
      return new ModifiedItemProcessor();
      }
     
  </code></pre>
  <p>the ModifiedItemProcessor is :</p>
  <pre><code>    public class ModifiedItemProcessor implements ItemProcessor&lt; MyServiceRequest, 
      MyServiceResponse &gt; {
      
      public MyServiceResponse process(MyServiceRequest item) {
      // interact with other Microservices and get the response
      return response;
  </code></pre>
  <p>the step is :</p>
  <pre><code>       @Bean
         protected Step step(@Qualifier(&quot;itemProcessor&quot;) ItemProcessor&lt;MyServiceRequest, 
         MyServiceResponse&gt; processor, ItemWriter&lt;MyServiceRequest&gt; writer) {
         return stepBuilderFactory
              .get(&quot;myStep&quot;)
              .&lt;MyServiceRequest, MyServiceResponse&gt; chunk(99)
              .reader(multiResourceItemReader())
              .processor(processor)
              .writer(writer)
              .build();
  }
  </code></pre>