View Full Version : Need to make a super simple program

06-21-08, 10:14 PM
All I need the ability to copy a few files from one directory to another but it needs to do this every 2 seconds or so.... im a complete programing novice but i have access to visual basic.


06-22-08, 05:48 PM
You need to be a little more specific

Where is the source of the file?
Where is the destination of the file?
What kind of file is it?
Are you looking to "read" the file and write its contents to a different file or do you want to copy the object itself(which brings more questions)?

edit: oh yeah, visual studio supports quite a few options for languages... you looking for something in java, c#, .NET...???

06-23-08, 07:41 AM
#! /bin/sh

while true; do
cp -dpR source destination
sleep 2

Especially if you only need to do this temporarily, a simple script should suffice just fine. Note that if you're processing large number of files, two second interval could prove to be a bit too short.

If you want to make copying smarter (only copy the files when they're changed), use rsync.

#! /bin/sh

while true; do
rsync -u source destination
sleep 2

If you want copying to /start/ every N seconds, you could replace the main loop with something like the following. It will /not/ handle fractions of seconds well so it's not very accurate.

n=10 # start copy every N seconds
before=$(date +%s)
while true; do
# copying happens here
after=$(date +%s)
sleep $(( n - after + before ))
before=after # save one call to date

If you're running Windows you can install Cygwin, or rewrite the script as batch-program.

06-26-08, 04:09 PM
i would do it with C# and i would make a GUI that allows you to specify the source directory and the target directory for the copy. also, do you want to rename the files each time?

06-26-08, 05:05 PM
For maximum ease, I'd just cheat. Make a super-super-simple VB app that has only two functions, a timer, and a bit of code to execute an external batch file. Here's how to do it:

1) Create a new VB project
2) Drag the timer icon onto the main program window
3) Double-click the timer
4) Paste the code below under the timer function -

Private Sub Form_Load()
Shell ("c:\copything.bat")
End Sub

(I think that should work, it's been about a year since I last wrote a VB app that called upon other exe's)
5) Add a button to the page, name it "Start"
6) Double-click it, enter


7) Compile, it should work.