We present a method of direct magnetic patterning of nonmagnetic CoC and CoTaC films by electron irradiation-induced nano-scale phase transition. CoxC1-x (0.4<X<0.8) films were prepared by co-sputtering. The as-deposited films with Co concentration less than 60% are amorphous and non-ferromagnetic. All films become ferromagnetic after annealing. Doping Ta into the CoC films can enhance the segregation of Co and C and therefore reduce the phase transition temperature. It is found that the magnetic properties of annealed (Co60C40)97Ta3 films are much better than that of annealed Co60C40 films at the same annealing condition. Magnetic nano-patterning (dot/line array) of the as-deposited CoC and Co(TaC) films was realized by subjecting them to electron irradiation using a focused 30keV electron beam with a current of 7.1 nA and dwell time per dot of 0.75 to 15.2 seconds. A 250nm magnetic dot/line array was produced by this method. It was also found that the time required to magnetically pattern non-magnetic (Co60C40)97Ta3 thin films (0.75 seconds) is much shorter than that required for Co60C40 films (3.8 seconds). The present method of magnetically patterning a nonmagnetic film has the potential application for nanoscale solid magnetic devices.