Solved

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

Posted on 2006-06-13
5
5,862 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 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Disclosure: Use this tutorial only when no other options helps to get Windows XP running without any problems and you don't want to format the drive. The back up of the data is the responsible of the user, however there is a description of how t…
There are 2 things you must have in order to connect to the internet behind a router, The "Gateway IP" of the router, which is usually something like 192.168.xxx.1, I've seen routers with default values of: 192.168.0.1, 192.168.1.1, 192.168.11.1, …
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 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