[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ROboscript to move a file to another Servers Directory

Posted on 2016-11-11
10
Medium Priority
?
89 Views
Last Modified: 2016-11-17
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
0
Comment
Question by:Twhite0909
  • 5
  • 2
  • 2
  • +1
10 Comments
 

Expert Comment

by:Antonio Jr Sun (VCP5-DCV)
ID: 41884474
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
 
LVL 71

Expert Comment

by:Qlemo
ID: 41884643
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
 

Author Comment

by:Twhite0909
ID: 41886533
Qlemo  it is just the preference of the IT director that we script using Robo
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 

Author Comment

by:Twhite0909
ID: 41886563
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
 
LVL 59

Expert Comment

by:Bill Prew
ID: 41886585
Since you have spaces in the pathnames you will need to enclose them in double quotes.

~bp
0
 

Author Comment

by:Twhite0909
ID: 41886635
like this?

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

Accepted Solution

by:
Bill Prew earned 2000 total points
ID: 41886649
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
 

Author Comment

by:Twhite0909
ID: 41886650
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
 

Author Comment

by:Twhite0909
ID: 41886653
That worked Bill TYVM!!  TY all for your assistance much appreciatted
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 41886659
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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

834 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