Search code examples
csvbatch-fileimportyiiyiic

How to run several yiic commands in one .bat file?


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.


Solution

  • 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