简体   繁体   English

如何在命令行中创建循环?

[英]How to create a loop in command line?

I tried this command 我试过这个命令

for /r %v in (*.abc) do abcconvert -toOgawa %v %v

and my result is : 我的结果是:

E:\PROGRAMMES\HOUDINI\bin>abcconvert -toOgawa E:\PROGRAMMES\HOUDINI\bin\Mesh01_00009.abc E:\PROGRAMMES\HOUDINI\bin\ParticleMesh01_00009.abc
Error: inFile and outFile must not be the same!

I just wrote one loop but its the same answer for all my loops. 我只写了一个循环,但对我所有的循环都回答相同。

I think my loop is good but i don't know how to change the name of my outfile.. i would like exactly the same path but just newfile0001 then newfile0002 and so on.. for example 我认为我的循环很好,但是我不知道如何更改输出文件的名称。例如,我想要完全相同的路径,只是newfile0001然后newfile0002等等。

I try to do this because i have a lot of files to convert and the original command to do this is : 我尝试这样做是因为我有很多文件要转换,而执行此操作的原始命令是:

abcconvert -toOgawa file.abc newfile.abc

good news: your loop works good. 好消息:您的循环效果不错。
The problem is %v %v , which is the very same filename for input and output. 问题是%v %v ,它是输入和输出的相同文件名。
You have to change it somehow. 您必须以某种方式进行更改。 See for /f near the end there are "modifiers". 看到for /f末尾有“修饰符”。

There are many ways to change the output file name, many of them can be done just with those modifiers. 更改输出文件名的方法有很多,其中许多可以使用这些修饰符来完成。

Simplest way: just change the extension: 最简单的方法:只需更改扩展名:

for /r %v in (*.abc) do abcconvert -toOgawa %v %~dpnv.new

ParticleMesh01_000000.new ParticleMesh01_000000.new

But you can also add a string to the filename (before the extension): 但是您也可以在文件名中添加一个字符串(在扩展名之前):

for /r %v in (*.abc) do abcconvert -toOgawa %v %~dpnv-new%~xv

ParticleMesh01_000000-new.abc ParticleMesh01_000000-new.abc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM