China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-04 06:45
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to generate new files for all files in a directory, with the new filenames the same as the original ones View 784 Replies 7
Original Poster Posted 2007-04-21 13:09 ·  中国 山东 济南 联通
初级用户
Credits 20
Posts 9
Joined 2007-04-21 00:17
19-year member
UID 85898
Gender Male
Status Offline
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 ]
Floor 2 Posted 2007-04-21 13:45 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
Use the for command together with the ~n expansion parameter, then add your custom extension.
Floor 3 Posted 2007-04-21 13:49 ·  中国 山东 济南 联通
初级用户
Credits 20
Posts 9
Joined 2007-04-21 00:17
19-year member
UID 85898
Gender Male
Status Offline
Say it a bit more specifically, the poster above
Floor 4 Posted 2007-04-21 13:59 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
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?
Floor 5 Posted 2007-04-21 14:42 ·  中国 北京 宽捷网通信技术有限公司
初级用户
Credits 84
Posts 28
Joined 2006-05-03 22:36
20-year member
UID 54894
Gender Male
Status Offline
Check for/? and you’ll understand
Floor 6 Posted 2007-04-21 14:47 ·  中国 广西 玉林 博白县 电信
金牌会员
★★★★
Credits 3,687
Posts 1,467
Joined 2005-08-08 12:00
20-year member
UID 44210
Status Offline
If it’s pure DOS, the ~n expansion parameter won’t work
Floor 7 Posted 2007-04-21 18:49 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
Does the OP want to do this under CMD or in pure DOS?
Floor 8 Posted 2007-04-21 21:15 ·  中国 山东 济南 联通
初级用户
Credits 20
Posts 9
Joined 2007-04-21 00:17
19-year member
UID 85898
Gender Male
Status Offline
Forum Jump: