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-07-31 22:27
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to run the latest executable file in a directory using batch processing? View 3,072 Replies 17
Floor 16 Posted 2007-03-13 07:28 ·  中国 浙江 绍兴 电信
高级用户
★★★
Autowalk
Credits 845
Posts 375
Joined 2007-03-03 01:58
19-year member
UID 80606
Gender Male
Status Offline
```code
@echo off
for /f "delims=" %%a in ('dir /od/b *.exe') do set name="%%a"
%name%


The second floor one has already been realized. It arranges the latest files at the end, using the characteristic of repeated assignment of set. When the for statement is executed, the last value assigned to name is the path of the latest file. What a clever idea! If it were me, I wouldn't be able to figure it out for a while, my brain is not enough, heh heh

[ Last edited by zhoushijay on 2007-3-12 at 06:29 PM ]
```
Floor 17 Posted 2007-03-13 14:23 ·  中国 北京 联通
银牌会员
★★★★
[b]看你妹啊[/b]
Credits 1,488
Posts 1,357
Joined 2006-05-20 12:00
20-year member
UID 55770
Status Offline
Originally posted by leton at 2007-3-13 06:53:
The owner seems to want to implement intelligent judgment of the latest executable file in the directory.

It's quite interesting. I'll study it when I have time. Early ideas:

Output file information to log.txt (information collection)
Then import...




:D You don't need to input into log.txt, ^_^ Have you seen the code?

The owner seems to want to implement intelligent judgment of the latest executable file in the directory.

Yes, this way, after the programmer updates the program, there's no need to modify the script code.

[ Last edited by yishanju on 2007-3-13 at 02:29 PM ]
Floor 18 Posted 2008-03-03 17:47 ·  中国 广东 广州 电信
新手上路
Credits 6
Posts 2
Joined 2008-03-03 13:29
18-year member
UID 111929
Gender Male
Status Offline
Originally posted by lxmxn at 2007-3-13 03:36 AM:
Put it in the directory where the file to be executed is located and run it. Not tested:

@echo off
for /f "delims=" %%a in ('dir /od/b *.exe') do set name="%%a"
%name%


As follows:
@echo off
for /f "delims=" %%a in ('dir /od/b *.exe') do set name=%%a
%name%
Forum Jump: