MoveFile on Windows 2003 Network

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
atapper
Newbie
Posts: 18
Joined: Wed Dec 17, 2008 2:10 pm
Location: Minnesota,USA

MoveFile on Windows 2003 Network

Post by atapper » Mon Jan 19, 2009 5:25 pm

I have written a script using the MoveFile command to move files from one network directory to another. When I tested the script using the exact same directory names and structure on my C: drive, it works perfectly. But when I substitute the network drive (G:/) the MoveFile command fails to do anything. It doesn't stop the script or give me any errors, it just doesn't move the file. ':cry:'

Interestingly I can move a file from the network drive(G:/) to my hard drive (C:/), but not the reverse. I have opened up the permissions (2003 NTFS) on the destination directory, but still no luck. :?

Anyone have any ideas?
Andrew Tapper
Engineering Manager
Forward Technology
Cokato, MN

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jan 19, 2009 7:19 pm

Can you post a code sample containing the movefile> command plus any other pertinent lines so we can examine your syntax.

atapper
Newbie
Posts: 18
Joined: Wed Dec 17, 2008 2:10 pm
Location: Minnesota,USA

Post by atapper » Mon Jan 19, 2009 8:33 pm

The following is the first part of the script (the rest is pretty much the same and some cleanup operations). It reads the path information from a file called Archive.cfg. The paths look like e:\Data\Forward_Tech\Archive and some other subdirectories. The files that should be moved by this section of code look like 2xxxxxx.dwg

As you can see from the code, I create a .log file that echoes where the MoveFile command should have moved the file from and to.

Another update: I have tried to run the compiled script directly from the server when logged on as admin, but it still doesn't work. And yet it still works on my computer with files on my hard drive. Any ideas would be greatly appreciated.


ReadFile>%SCRIPT_DIR%\Archive.cfg,data_file
Separate>data_file,%CRLF%,rw
Let>Review=%rw_1%
Length>Review,rLen
Let>rLen=rLen+2
Let>Archive=%rw_2%
Let>Old_Archive=%rw_3%
Let>Log=%rw_4%
GetFileList>%Review%\2*.dwg,dwgFile
GetFileList>%Review%\2*.zip,zipFile
Separate>dwgFile,;,dwgFile_name
Separate>zipFile,;,zipFile_name
Let>d=0
Let>z=0
Day>Dy
Month>Mth
Year>Yr
ConCat>Mth,Dy
ConCat>Mth,Yr

/*Move the *.dwg files*/
If>dwgFile_name_countd
Let>d=d+1
Let>Temp=dwgFile_name_%d%
Length>Temp,fLength
MidStr>Temp,rLen,fLength,dwgName
MidStr>dwgName,1,3,dwgStart
Length>dwgName,nLength
Let>NamLen=nLength-4
Let>ExtLen=nLength-3
MidStr>dwgName,1,NamLen,NameOnly
MidStr>dwgName,ExtLen,nLength,Ext
IfFileExists>%Archive%\%dwgStart%\%dwgName%
IfFileExists>%Old_Archive%\%dwgStart%\%NameOnly%_%Mth%%Ext%
DeleteFile>%Old_Archive%\%dwgStart%\%NameOnly%_%Mth%%Ext%
Endif
MoveFile>%Archive%\%dwgStart%\%dwgName%,%Old_Archive%\%dwgStart%\%NameOnly%_%Mth%%Ext%
WriteLn>%Log%\ArchiveLog_%Mth%.txt,nWLNRes,%Archive%\%dwgStart%\%dwgName% was moved to %Old_Archive%\%dwgStart%\%NameOnly%_%Mth%%Ext%
EndIf
MoveFile>Temp,%Archive%\%dwgStart%\%dwgName%
WriteLn>%Log%\ArchiveLog_%Mth%.txt,nWLNRes,%Temp% was moved to %Archive%\%dwgStart%\%dwgName%

Until>d,dwgFile_name_count
EndIf
Andrew Tapper
Engineering Manager
Forward Technology
Cokato, MN

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jan 19, 2009 10:55 pm

The line:
If>dwgFile_name_countd
Looks like it was changed by the forum. When you post code turn off (disable) HTML and Smilies. Since I don't have your cfg file I can't actually confirm all that is working. But if your log file file names look correct, you are most likely reading from the cfg file and parsing the data correctly.

Just a thought:
Since these files are on the server, is it possible they are in use by someone on the network? If you go to the server, open a DOS window, type in "net file" (less the quotes) and press return, do your files show up in the list? If they do, the server believes that the files are in use and will not allow you to move them, delete them, or open them.

atapper
Newbie
Posts: 18
Joined: Wed Dec 17, 2008 2:10 pm
Location: Minnesota,USA

Post by atapper » Mon Jan 19, 2009 10:56 pm

Yeah, I forgot about disabling the HTML/Smiles. The line reads:
If>dwgFile_name_count0

I will try the in use idea. I know nobody was using the all the files at the time, but that doesn't mean that Windows didn't think that they were.

Thanks
Andrew Tapper
Engineering Manager
Forward Technology
Cokato, MN

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jan 19, 2009 11:01 pm

If the line is:
If>dwgFile_name_count0

are there any lines that got left out?

In the posted code you have not initialized the "d" variable and there is an Until> that does not have a beginning Repeat>

atapper
Newbie
Posts: 18
Joined: Wed Dec 17, 2008 2:10 pm
Location: Minnesota,USA

Post by atapper » Mon Jan 19, 2009 11:07 pm

OK, somehow I lost the Repeat>d line too.

Really, it is in the code I tried to post and it does work when I run it on my computer, just not with the network files.

I am disabling all Smiles from now on. :D
Andrew Tapper
Engineering Manager
Forward Technology
Cokato, MN

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jan 19, 2009 11:10 pm

I believe you. You're from a small town in Minnesota. You're as honest as someone from a small town in Iowa.




post#1234

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Jan 20, 2009 10:04 am

We have a Windows 2003 network server here and I am unable to replicate a problem moving files with MoveFile across any Windows 2003 network shares. It works fine. So I can't explain why you're having an issue.

However, if all else fails you could just use the windows MOVE command:

Let>RP_WINDOWMODE=0
Let>RP_WAIT=2
Run>cmd.exe /c move %sourcefile% %destination%

Try it manually from the command line first.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

atapper
Newbie
Posts: 18
Joined: Wed Dec 17, 2008 2:10 pm
Location: Minnesota,USA

Post by atapper » Tue Jan 20, 2009 3:03 pm

So I tried the code listed below. The RP_RESULT I got was 259, but the file still did not move! I am completely stumped.

Let>sourcefile=G:\Archive\Review New\2157009.dwg
Let>destination=G:\Archive\2\215\2157009.dwg
Let>RP_WINDOWMODE=0
Let>RP_WAIT=2
Run>cmd.exe /c move %sourcefile% %destination%
Message>%RP_RESULT%
Andrew Tapper
Engineering Manager
Forward Technology
Cokato, MN

atapper
Newbie
Posts: 18
Joined: Wed Dec 17, 2008 2:10 pm
Location: Minnesota,USA

Post by atapper » Tue Jan 20, 2009 3:26 pm

OK, so I made the window cmd work by taking the spaces out of my directory name, but the MoveFile command still doesn't work.
Andrew Tapper
Engineering Manager
Forward Technology
Cokato, MN

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Jan 20, 2009 3:38 pm

DOS/Windows wants quotes if you have spaces. So try:

Run>cmd.exe /c move "%sourcefile%" "%destination%"
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

atapper
Newbie
Posts: 18
Joined: Wed Dec 17, 2008 2:10 pm
Location: Minnesota,USA

Post by atapper » Tue Jan 20, 2009 5:16 pm

So this is my official crow eating post. The problem was that I had forgot a directory level on my destination. :oops:

The hardest problems have the dumbest answers!

Thank to everyone for their help.
Andrew Tapper
Engineering Manager
Forward Technology
Cokato, MN

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Jan 20, 2009 6:47 pm

We've all been there one way or another. Thank you for fessing up. Its always more satisfying to hear the answer (even a "dumb" one) than to spend time thinking about and working on a posters issue, then, never hearing whether their problem was solved.

Also its good to know that once more, a Macro Scheduler function is vindicated. :wink:

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts