“Input line is too long” in BAT files

匆匆过客 提交于 2019-12-08 11:44:17

问题


I need to compile my .jar file many times in a day, so I got a idea I could make a BAT file to compiler faster here it is:

call "jar cmf 'META-INF/MANIFEST.MF' 'Bounce Tales.jar' a a.class aa.png ab.png ac.png ad.png ae.png af.png ag.png ah.png ai.png aj.png ak.png al.png am.png an.png ao.png ap.png aq.png ar.png as.png at.png au.png av.png aw.mid ax.mid ay.mid az.mid b b.class ba.mid bb.mid bc.mid bd.mid be bf bg bh bi bj bk bl bm bn bo bp bq br bs bt bu bv c.class c.png d.class d.png e.class e.png f.class f.png g.class g.png h.class h.png i.class i.png icon.png j.class j.png k.class k.png l.class l.png lang.bs-BA lang.cs-CZ lang.de lang.hr-HR lang.hu-HU lang.mk-MK lang.sk-SK lang.sl-SI lang.sq lang.sr-YU lang.xx m.class m.png n.class n.png o.class o.png p.class p.png q.class q.png r.class r.png RMIDlet.class s.png t.png u.png v.png w.png x.png y.png z.png"

This resulted a error:

The input line is too long.

I don't have any idea how to make it shorter, and when I copypaste the command to the console, it compiles just fine...


回答1:


You can break your line up into several variables, and use them to call your process. That's the way we used to get the path longer than the number of characters MSDOS limited a command-line to.

set a=a a.class aa.png ab.png ac.png ad.png ae.png af.png ag.png ah.png ai.png aj.png ak.png al.png am.png an.png ao.png ap.png aq.png ar.png as.png at.png au.png av.png aw.mid ax.mid ay.mid az.mid 

set b=b b.class ba.mid bb.mid bc.mid bd.mid be bf bg bh bi bj bk bl bm bn bo bp bq br bs bt bu bv c.class c.png d.class d.png e.class e.png f.class f.png g.class g.png h.class h.png i.class i.png icon.png j.class j.png

set c=k.class k.png l.class l.png lang.bs-BA lang.cs-CZ lang.de lang.hr-HR lang.hu-HU lang.mk-MK lang.sk-SK lang.sl-SI lang.sq lang.sr-YU lang.xx m.class m.png n.class n.png o.class o.png p.class p.png q.class q.png

set d= r.class r.png RMIDlet.class s.png t.png u.png v.png w.png x.png y.png z.png

call "jar cmf 'META-INF/MANIFEST.MF' 'Bounce Tales.jar' %a% %b% %c% %d%"



回答2:


This question is a copy of: how to increase the input line length(max) in windows?

To run a batch file with a long input string, you have to delimit it with the ^ character.

call "jar cmf 'META-INF/MANIFEST.MF' 'Bounce Tales.jar' a a.class aa.png ab.png ac.pngad.png ae.png af.png ag.png ^
ah.png ai.png aj.png ak.png al.png am.png an.png ao.png ap.png aq.png ar.png as.png at.png au.png av.png aw.mid ax.mid ^
ay.mid az.mid b b.class ba.mid bb.mid bc.mid bd.mid be bf bg bh bi bj bk bl bm bn bo bp bq br bs bt bu bv c.class ^
c.png d.class d.png e.class e.png f.class f.png g.class g.png h.class h.png i.class i.png icon.png j.class j.png ^
k.class k.png l.class l.png lang.bs-BA lang.cs-CZ lang.de lang.hr-HR lang.hu-HU lang.mk-MK lang.sk-SK lang.sl-SI ^
lang.sq lang.sr-YU lang.xx m.class m.png n.class n.png o.class o.png p.class p.png q.class q.png r.class r.png ^
RMIDlet.class s.png t.png u.png v.png w.png x.png y.png z.png"



回答3:


Okay, I found it. I used this:

jar cmf "META-INF/MANIFEST.MF" "Bounce Tales.jar" a a.class aa.png ab.png ac.png ad.png ae.png af.png ag.png ah.png ai.png aj.png ak.png al.png am.png an.png ao.png ap.png aq.png ar.png as.png at.png au.png av.png aw.mid ax.mid ay.mid az.mid b b.class ba.mid bb.mid bc.mid bd.mid be bf bg bh bi bj bk bl bm bn bo bp bq br bs bt bu bv c.class c.png d.class d.png e.class e.png f.class f.png g.class g.png h.class h.png i.class i.png icon.png j.class j.png k.class k.png l.class l.png lang.bs-BA lang.cs-CZ lang.de lang.hr-HR lang.hu-HU lang.mk-MK lang.sk-SK lang.sl-SI lang.sq lang.sr-YU lang.xx m.class m.png n.class n.png o.class o.png p.class p.png q.class q.png r.class r.png RMIDlet.class s.png t.png u.png v.png w.png x.png y.png z.png

I put that in the BAT file.



来源:https://stackoverflow.com/questions/12751809/input-line-is-too-long-in-bat-files

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!