General discussion

Locked

Batch Scripting - If ELSE Statements

By jhallstrom ·
Hello,

I am trying to create a script that will move certain file types from an FTP folder and move them to a working directory.

Here is what I have - will this work?

CD C:\incoming\TESTFTP

IF EXIST *artrm.* (Copy *artrm.* C:\work)
ELSE (ECHO NO FILES TO MOVE)

I am trying to move all files named artrm.*

What am I missing or is there a better way to do this?

Thanks

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Depends

by GSG In reply to Batch Scripting - If ELSE ...

First, if you post this in the questions forum, you'll get a wider audience. We have a lot of people who check the Questions forum who don't frequent the discussions forum. Plus, you can give a "Thumbs Up" over there to the folks that give you a good answer.

Unless I'm missing something, you may be making this more difficult than it really needs to be. Do you really need to Echo "No files to move"? Also, you shouldn't really need to change your directory. If you don't need to do the Echo, here's what I'd do if you're running the batch on the server where the files reside:

move drive:\foldername\*artrm.* c:\foldername

That will move the documents without leaving the original in the directory like copy will.

I have one server where I run all my batches, and I put them in one folder at C:\BatchFiles for ease of management. I typically would have a bat file moving from that server to another server, which would look like this:

move c:\foldername\*artrm.* \\servername\sharename

That's all one line with a single space between *artrm.* and \\servername

The batch won't run in silent mode when you do it this way, so you can see it running. You can then schedule the bat file to run whenever you need it. We have one that runs every few seconds, and others that we've scheduled to run once an hour.

I hope this helps.

Back to Software Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums