中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-04 07:52
48,038 topics / 350,123 posts / today 0 new / 48,251 members
DOS批处理 & 脚本技术(批处理室) » How to generate new files for all files in a directory, with the new filenames the same as the original ones
Printable Version  786 / 7
Floor1 xlfj521 Posted 2007-04-21 13:09
初级用户 Posts 9 Credits 20
I’m using a tool, and in DOS with a batch file
I want to generate a new file for every file in that folder, and at the same time have the new file use the same filename as the source file, but with a different extension. How do I do that? :o

[ Last edited by xlfj521 on 2007-4-21 at 08:15 AM ]
Floor2 lxmxn Posted 2007-04-21 13:45
版主 Posts 4,938 Credits 11,386
Use the for command together with the ~n expansion parameter, then add your custom extension.
Floor3 xlfj521 Posted 2007-04-21 13:49
初级用户 Posts 9 Credits 20
Say it a bit more specifically, the poster above
Floor4 lxmxn Posted 2007-04-21 13:59
版主 Posts 4,938 Credits 11,386
First use for to iterate through the contents of the folder, then generate the file as you want, and then use the %~na form to expand the filename; add the extension and that’s it. Isn’t that specific enough?
Floor5 waynebeat Posted 2007-04-21 14:42
初级用户 Posts 28 Credits 84
Check for/? and you’ll understand
Floor6 zh159 Posted 2007-04-21 14:47
金牌会员 Posts 1,467 Credits 3,687
If it’s pure DOS, the ~n expansion parameter won’t work
Floor7 lxmxn Posted 2007-04-21 18:49
版主 Posts 4,938 Credits 11,386
Does the OP want to do this under CMD or in pure DOS?
Floor8 xlfj521 Posted 2007-04-21 21:15
初级用户 Posts 9 Credits 20
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023