Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2006-06-13
5
Medium Priority
?
5,867 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 5

Accepted Solution

by:
mkdonohue earned 2000 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 Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you build your web application in Visual Studio you'll get at least a few binaries, or .DLL, files in your bin folder. However, there is more compiling to be done. Normally this would happen when an ASP.NET resource within the web site is request…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

722 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