0

I have an ImportCommand class which reads a file and imports the data from that file to a database. The command itself works fine.

However, I need to run the same command several times with different files.

My .bat file:

@echo off
cd c:\xampp\htdocs\mysite\protected\
yiic import c:\sourcefiles\users_1.csv
yiic import c:\sourcefiles\users_2.csv
yiic import c:\sourcefiles\users_3.csv

The first command runs then the script stops and files users_2.csv and users_3.csv are not processed.

icodebuster
  • 8,780
  • 7
  • 59
  • 63
boliviandev
  • 11
  • 1
  • 3

3 Answers3

1

After struggling with this for a while, I found this answer: How to run multiple .BAT files within a .BAT file

So the .bat file should be:

@echo off
cd c:\xampp\htdocs\mysite\protected\`
call yiic import c:\sourcefiles\users_1.csv
call yiic import c:\sourcefiles\users_2.csv
call yiic import c:\sourcefiles\users_3.csv 
Community
  • 1
  • 1
boliviandev
  • 11
  • 1
  • 3
1

Use CALL command. Without CALL, control is transferred to other batch and is not returned.

LS_ᴅᴇᴠ
  • 10,327
  • 1
  • 18
  • 44
0

Try this

@echo off
cd c:\xampp\htdocs\mysite\protected\
yiic import c:\sourcefiles\users_1.csv && yiic import c:\sourcefiles\users_2.csv && yiic import c:\sourcefiles\users_3.csv

This will execute the desired command one by one . It only proceeds one operation is successful.

kebyang
  • 569
  • 3
  • 9
  • 23