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-29 07:59
中国DOS联盟论坛 » 论坛回收站 » Newcomer asks a newbie question View 8,731 Replies 2
Original Poster Posted 2010-12-02 09:27 ·  中国 重庆 九龙坡区 电信
新手上路
Credits 10
Posts 9
Joined 2010-10-22 21:12
15-year member
UID 176356
Gender Male
Status Offline
The function of the code is to find all MP3 files in each D drive and its subfolders.

Dim WshShell
set WshShell = CreateObject("wscript.Shell")
WshShell.Run "d:\findfile.bat"

The code in findfile.bat is as follows:
@echo off
dir *.mp3 /a-d /b /s>>result.txt
pause

This is the VBS I wrote to run a bat code, but it always prompts that the file is not found. Depressed. I don't know the reason. The output result is also not good. Why?
Floor 2 Posted 2010-12-02 11:26 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
Credits 1,039
Posts 897
Joined 2009-03-01 15:34
17-year member
UID 140302
Gender Male
From 在地狱中仰望天堂
Status Offline
Floor 3 Posted 2010-12-02 14:35 ·  中国 重庆 九龙坡区 电信
新手上路
Credits 10
Posts 9
Joined 2010-10-22 21:12
15-year member
UID 176356
Gender Male
Status Offline
Set fso = CreateObject("scripting.filesystemobject")
Set Shell = CreateObject("Shell.application")
Set aa = Shell.BrowseForFolder(0, "Please select the folder:", 0)
p=aa.Self.Path
fso.CopyFile "d:\findfile.bat",p

I want to first select a folder (using the VBS method), and then read the MP3 files in the subfolders and all folders below. So I thought of this method: copy the BAT file that reads MP3 files to the selected folder, and then execute it. Because I don't know how to pass the return value of the VBS path to the BAT, I can only copy the BAT to the corresponding folder and then run it.

But it seems that when running, the path executed in the BAT is the folder where the VBS file is located. The return value is incorrect. It shows that the file is not found. I don't know if I explained it clearly.

Because I mainly want to use the file selection dialog function of VBS. I'm not very good at using BAT. I haven't learned variable delay yet.
Forum Jump: