Solved

'IF EXIST' in a .bat script to test for an empty directory

Posted on 2006-06-13
5
5,853 Views
Last Modified: 2008-01-09

I would like to test if an directory is empty, using a simple batch script.
I wrote the following line:


if not exist "%ProgramFiles%\Epos9300\nul" echo Path does not exist

My Problem is:
I want to run this batch file in Windows XP operating systems with different languages.
For example in the English windows version the system variable %ProgramFiles% includes a white space.  (...\Program Files\...)


Therefore I must put the whole path into double quotas.
But with double quotas the 'exist' command does not recognize an empty directory anymore.
0
Comment
Question by:Boskop
5 Comments
 
LVL 5

Accepted Solution

by:
mkdonohue earned 500 total points
ID: 16897983
Why not just CD to the %ProgramFiles% directory in your scrip and then check for the existance of Epos9300\nul?
0
 
LVL 2

Expert Comment

by:smilingpolitely
ID: 16898039
Alternatively, use the valid shortname for %ProgramFiles% - e.g. C:\Progra~1\
0
 
LVL 1

Author Comment

by:Boskop
ID: 16906679
mkdonohue, it's a good idea. Maybe there is one other suggestion to do it without changing the current path.

smilingpolitely, with your solution it is not sure that this is the real path name. Maybe it's C:\Progra~2\ or C:\Whewhe~1\ in another language like suaheli.
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Are you unable to synchronize your OST (Offline Storage Table) file with Microsoft Exchange Server? Is your OST file exceeding 2 GB size limit? In Microsoft Outlook 2002 and earlier versions, there is a 2 GB size limit for the OST file. If the file …
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup". After a while, you have entered a loop for Auto repair which does not fix anything and you will be in a  panic as all your work w…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now