Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

vb.net move files from one folder to another on a schedule

Posted on 2013-06-25
11
Medium Priority
?
562 Views
Last Modified: 2013-06-26
I have a folder on my FTP server.  I need to take the files in it and move them to a different folder every 10 minutes.  Looking for either ideas on doing this using vb.net or a program already out there?
0
Comment
Question by:bergertime
[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
  • 4
  • 4
  • 3
11 Comments
 
LVL 11

Assisted Solution

by:lenordiste
lenordiste earned 400 total points
ID: 39275564
just my thoughts on some possible solutions.
- use a worflow management tool (System Center Orchestrator if you're a windows guy?): smallest amount of work but you need the software / license
- develop a worflow in .NET with WorKFlow Foundation: needs a bit of work and may be overkill if your workflow is very simple.
- develop a VB.NET windows service with a ten minute timer: a bit of work but it's a proven working method.
- develop a VB.NET batch and use a task scheduler to launch it every 10 minutes: not much work to do but you have to like windows task scheduler

of course, do use a FTP library which handles move commands (rename) !

Happy to exchange on those thoughts with you or other experts :) !
0
 
LVL 16

Expert Comment

by:AlexPace
ID: 39276109
Robo-FTP can be scripted to do this and can install as a Windows Service that does the work, sleeps for ten minutes, works, sleeps, works, sleeps and so on... something like:

:start
FTPLOGON "myftp.server.com" /user="UserID" /pw="secret" 
FTPCD "/source" 
:find_file_to_move
FTPGETFILE "*" 
IFERROR GOTO done
SET new_name = "/destination/folder/" + %sitefile 
FTPRENAME %sitefile new_name    ;; rename file's path to move it on an FTP site 
IFERROR GOTO done  ;; this is a failsafe... it shouldn't happen
GOTO find_file_to_move 
:done 
FTPLOGOFF  ;; harmless error if not connected 
PAUSE /for=600    ;; Ten mins is 600 seconds ...
GOTO start

Open in new window


The Robo-FTP license will set you back $150 but, if this is for work purposes, your boss will probably spend at least that on one hour of your programming time so maybe it would be worth it considering that it is supported commercial software and might be useful for automating other things in your office.
0
 
LVL 11

Expert Comment

by:lenordiste
ID: 39276160
in case you need a free library, consider these:
http://ftps.codeplex.com/http://ftps.codeplex.com/
http://www.enterprisedt.com/products/edtftpnet/overview.html

I have never used Robo-FTP but if it does the job $150 for a licence is not a rip-off :)
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
LVL 2

Author Comment

by:bergertime
ID: 39276217
AlexPace, ok RoboFTP is cool, one question, can I rename the files as they are being moved?  Say the file is MyFTPDocument.edi and I want it to be data1.edi, data2.edi, data3.edi.......etc.  Otherwise for 150 this will be used a lot.  Thanks
0
 
LVL 11

Expert Comment

by:lenordiste
ID: 39276280
in FTP there's no "move" per say. Moving a file is actually renaming it :-) of course you rename the whole path including file names, hence both the file name and the folder can be changed.
0
 
LVL 16

Expert Comment

by:AlexPace
ID: 39276418
Yes you could use a counter to give names like data1.edi, data2.edi, data3.edi and just increment the counter in the loop... but if you could get away with also adding a date then you'll also solve the problem of overwriting a file with another file that has the same name.

For example, suppose the computer reboots and it restarts script counter at 1 but you already have a saved file named data1.edi so that file gets overwritten. You could use the %datetime variable along with a number to guarantee each file name was unique like this:

SETNUM counter = 00000
:start
FTPLOGON "myftp.server.com" /user="UserID" /pw="secret" 
FTPCD "/source" 
:find_file_to_move
FTPGETFILE "*" 
IFERROR GOTO done
INC counter  ;;   increment the counter variable 
SET new_name = "/destination/folder/data" + counter + %datetime + ".edi" 
FTPRENAME %sitefile new_name    ;; rename file's path to move it on an FTP site 
IFERROR GOTO done  ;; this is a failsafe... it shouldn't happen
GOTO find_file_to_move 
:done 
FTPLOGOFF  ;; harmless error if not connected 
PAUSE /for=600    ;; Ten mins is 600 seconds ...
GOTO start

Open in new window


Another idea that does not include a date might be to use a text file file to keep the last used number persistent through reboots ... the READFILE and WRITEFILE commands would help you do that.  You could do the same thing with a database table and commands like DBQUERY and DBGETRESULTS but that is overengineering it a bit I think I would stick with the text file if I had to have persistent numbering.
0
 
LVL 2

Author Comment

by:bergertime
ID: 39276444
Alex, good.  I have to keep the name under 10 charactors, I had tried to use the date just the minutes and seconds,  but it's no big deal, once they get renamed, they get consumed and deleted so reboots are no big deal.  But it's the strangest thing.  I have 10 test samples in my folder.  First pass through it gets a few, next pass through it gets a few more.....always the same files until they all get renamed.  I think I can get it from here.  Thank you so much.  Just wondering if you had seen it missing some of them.
0
 
LVL 16

Accepted Solution

by:
AlexPace earned 1600 total points
ID: 39276481
Oh, yeah... I've seen that... try using GETSITEFILE instead of FTPGETFILE on line 6
0
 
LVL 2

Author Comment

by:bergertime
ID: 39277962
Dude, you rock.
0
 
LVL 2

Author Closing Comment

by:bergertime
ID: 39277966
Thanks for making something boring and tedious actually kind of fun.
0
 
LVL 16

Expert Comment

by:AlexPace
ID: 39278482
Thanks for the kind words!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

610 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