Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

[BATCH] File search problem

Original Message
Name: Faiden
Date: May 11, 2008 at 02:14:03 Pacific
Subject: [BATCH] File search problem
OS: XP
CPU/Ram: 20048
Model/Manufacturer: -
Comment:
Hi i got a tricky problem with a batch file im trying to make and i hope yu guys can help me

this is my Batch atm.

:Start
SET FILE=
SET /P FILE=Type the name of the file and press enter:
IF EXIST C:\Docume~1\%username%\Desktop\%FILE%.* GOTO FileYes
Goto FileNo
:FileYes
CLS
ECHO *** STARTING %File%
START C:\Docume~1\%username%\Desktop\%FILE%
GOTO END
:FileNo
CLS
SET Choice=
SET /P Choice=The file "%FILE%" was not found try again [Y,N]?
IF /I '%Choice%'=='Y' GOTO START
IF /I '%Choice%'=='N' GOTO END
:END

As the user that types in the file name dosent know the file ending like "text.txt"
the user only knows "text"
how do i search for the right file name from %FILE% and return the whole name of the file to START?


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: May 11, 2008 at 02:37:11 Pacific
Subject: [BATCH] File search problem
Reply: (edit)
[1] No need to clear the var just before you set it.

[2] Probably a good idea to use the LFN path instead of docume~1

[3[ Assuming there's only one file named test, after doing the 'if exist', do this:

for /f "tokens=* delims= " %%a in ('dir/s/b "c:\Documents and Settings\%username%\Desktop\%FILE%.*"') do (
start "%%a"
)


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal

Response Number 2
Name: Faiden
Date: May 11, 2008 at 02:52:03 Pacific
Subject: [BATCH] File search problem
Reply: (edit)
Ahh nice that what was i was thinking tnx alot

fast answer and everything

just one more question

i whant to print out this to another file

like
Echo Start "" c:\Documents and Settings\%username%\Desktop\%FILE% >>Somefile.bat

how do i get the correct file at the end of that file?

sorry if i was to unclear the first time

and yes there is only one file named "test"


Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: May 11, 2008 at 03:54:56 Pacific
Subject: [BATCH] File search problem
Reply: (edit)

for /f "tokens=* delims= " %%a in ('dir/s/b "c:\Documents and Settings\%username%\Desktop\%FILE%.*"') do (
> some.bat echo start "%%a"
)


=====================================
If at first you don't succeed, you're about average.

M2


Report Offensive Follow Up For Removal




Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: [BATCH] File search problem

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




Batch File- Current Date in Excel

how to setup call of duty to joytok

WindowsME / HotMail Problem

Corrupt memory

Convert fat32 to Ntfs


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC