Computing.Net > Forums > Windows XP > batch script to set default value

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

batch script to set default value

Reply to Message Icon

Name: bearc
Date: December 29, 2008 at 16:05:08 Pacific
OS: Windows XP
CPU/Ram: Athlon x2 5200+ / 2G
Product: Dell / INSPIRON 1525
Comment:

Hello!
I need to make a .bat, that process a text
file. The text file name is the first
parameter of the batch file call. If no
parameter is present, then the default value
for the text file must be "a.txt"

something like this:

set inputfile=%1
if %1=="" set inputfile=a.txt
echo %inputfile%

but this "script" does not work, can anyone
help me please?




Sponsored Link
Ads by Google

Response Number 1
Name: kptech
Date: December 29, 2008 at 18:41:35 Pacific
Reply:

bearc,

Try including double quotes (") on both sides of the ==, like this:

set inputfile=%1
if "%1"=="" set inputfile=a.txt
echo %inputfile%

The Windows batch language has a problem processing the %1 parameter when it's value is nul.


0

Response Number 2
Name: bearc
Date: December 29, 2008 at 21:39:35 Pacific
Reply:

It works

many many many thanks !

again, computing.net is the best place to get
scripting help

If I'm not wrong, in Linux there is a similar
issue with empty strings



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: batch script to set default value

Batch script to rename files www.computing.net/answers/windows-xp/batch-script-to-rename-files/173968.html

how to set default volume level www.computing.net/answers/windows-xp/how-to-set-default-volume-level-/171726.html

Batch script to auto rename subtitles files www.computing.net/answers/windows-xp/batch-script-to-auto-rename-subtitles-files/176811.html