ROboscript to move a file to another Servers Directory

I need a robo script to move a file from this server's location to another.  We use Roboscript.  This is an FTP server and the file is sent to us everyday to the ftp directory.  I want to script the file to be moved to another servers directory everyday


File arrives:   \\sftp.company.com\customers\companya\file.txt

Move FIle to :  Server 01\customers\companya
Twhite0909Asked:
Who is Participating?
 
Bill PrewCommented:
Both paths, since the first has a space too, so:

move-item "D:\WS_FTP Server\sftp.companya.com\users\customer1\*" "P:\Welcome Letters"

Open in new window

~bp
0
 
Antonio Jr Sun (VCP5-DCV)Infrastructure EngineerCommented:
Alternative solution. Hope this will help.

This simple can be done using powershell script save as .ps1 extension

for (;;) {
    move-item c:\source\* c:\destination
}
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
What is the exact issue? And why using RoboScript for something that simple?
I would just set up a scheduled task running once a day a regular (x)copy.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
Twhite0909Author Commented:
Qlemo  it is just the preference of the IT director that we script using Robo
0
 
Twhite0909Author Commented:
Antonio I tried to write a .ps1 using your script but get errors.  Ive attached a copy of the script text file.  It errors and states" Move-Item : A positional parameter cannot be found that accepts argument"
movefilescript.jpg
0
 
Bill PrewCommented:
Since you have spaces in the pathnames you will need to enclose them in double quotes.

~bp
0
 
Twhite0909Author Commented:
like this?

for (;;) {
    move-item D:\WS_FTP Server\sftp.companya.com\users\customer1\* "P:\Welcome Letters"
}
0
 
Twhite0909Author Commented:
so basically what Im trying to do here is have the script pull any and all files that exist in the source directory and dump them in the destination directory.  Sometimes it may be different file types .csv or .txt and sometimes the number of files will range from 1-200 so I need a script that looks in the source folder then grabs everything in there and movers it to the destination folder.  BAsed on that how can I make the below work.  

or (;;) {
    move-item D:\WS_FTP Server\sftp.companya.com\users\customer1\* "P:\Welcome Letters"
}



Also when I try it like this by putting double quotes on entire line  I see cmd execute 1,000 times but the file is never moved

or (;;) {
    "move-item D:\WS_FTP Server\sftp.companya.com\users\customer1\* P:\Welcome Letters"
}
0
 
Twhite0909Author Commented:
That worked Bill TYVM!!  TY all for your assistance much appreciatted
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
But you never should do that endless loop stuff without at least an sleep! If you do not want to use a scheduled task, as I have recommended, run this:
while ($true)
{
  move-item 'D:\WS_FTP Server\sftp.companya.com\users\customer1\*' 'P:\Welcome Letters'
  sleep 86400
}

Open in new window

This runs the command once a day (86400 seconds). Switch to e.g. 3600 for an hourly move.

Side note: Single quotes are "literal string quotes", while double quotes allow for replacing variables and expressions inside the string. To be save, it is good practise to use single quotes whenever you do not want to have variable expansion inside the string happen.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.