Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

DOS Script - Check if a folder is empty

Posted on 2009-02-09
7
Medium Priority
?
933 Views
Last Modified: 2013-11-10
During my daily processing, I need to move files from a source(incoming) folder to a target(processing) folder. Once the file is in my target folder, I kick off my application which processes this file. After my application completes processing, another script moves the file out of the processing folder.
Before I move my files from the incoming to the processing folder, I want to ensure that my processing folder is empty. I saw some solutions to the problem using the FOR command, but that command doesn't work at this client. How do I ensure that my target foler is empty before moving any new files into it?
0
Comment
Question by:mightyestme
  • 4
  • 3
7 Comments
 
LVL 97

Expert Comment

by:Lee W, MVP
ID: 23596215
What do you mean the FOR command doesn't work at that client?  The For Command is built in to Windows Server.  How does it now work?  (are you trying to run it in command.com instead of cmd.exe?)
0
 

Accepted Solution

by:
mightyestme earned 0 total points
ID: 23596390
I did run cmd.exe
The error I used to get is:
'for' is not recognized as an internal or external command, operable program or batch file

Same for find. After reading your comment, when I tried to run for and find again, it says syntax not correct. So these commands do seem to be working now. I am at a client who are extremely restrictive, and I guess something might have changed since the last time I tried this out.

If possible, I would still like to see a solution to this problem without using for/find simply because I am not sure if my automation user will have access to these commands, and I don't want it to fail the first time it runs.

One more pointer: My target folder, if not empty, will contain files starting with DET*. I tried using:

if exist %Tgt%\DET*.* (
write to log file
exit 1
)

This seems to be working. I was looking for a more elegant solution, where I don't need to use the DET*.* option.
0
 
LVL 97

Expert Comment

by:Lee W, MVP
ID: 23596397
That kind of error suggests the server's path statement is messed up.  Can you post it?
0
Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

 

Author Comment

by:mightyestme
ID: 23596470
I will post the PATH as soon as possible. I have access to the server only 2 hours a day, and my 2 hours for today are now up. (This is not even production yet).

Again, a solution without fancy commands and reasonably flexible would be enough.
0
 

Author Comment

by:mightyestme
ID: 23608047
Here is the path variable:

Path=C:\Program Files\Support Tools\;C:\Program Files\HP\NCU;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\IBM\DB2RuntimeClient 7\bin\;C:\Program Files\IBM\DB2RuntimeClient 7\function;C:\Program Files\IBM\DB2RuntimeClient 7\help\;C:\Program Files\BMC Software\Control-M Agent\Default\EXE\;C:\Program Files\GnuWin32\bin;C:\Program Files\Microsoft SQL Server\90\Tools\binn\
0
 
LVL 97

Expert Comment

by:Lee W, MVP
ID: 23608606
ok, that looks good... can you take a screen shot of the FOR command failing?  where it displays the command executed and the error message?
0
 

Author Comment

by:mightyestme
ID: 23610508
the for isn't failing now, it used to be failing in the past. I tried again today, and it worked.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Introduction to Processes

578 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