#69593 - 2002-09-01 02:08 PM
Archiving files using robocopy
|
Tom Hagen
Fresh Scripter
Registered: 2001-11-02
Posts: 7
Loc: Milwaukee, WI
|
ScriptLogic version: KiXtart 4.10
I'm trying to archive files using Robocopy the main reason is the speed and compression it goes at. I did not want to use the copy and delete command in Kix because Robocopy will also remove the folder if no other files or folders are in the structure which is what I want/need.
I have a utility that tells me where deleted user's folder and file are currently and eports that info into a csv file. I need the files to move to a central location. The code works great until it comes accoss spaces in the folder or file names, which is now very common. When shelling out kix now does not pass the correct statements. As you will see I did put in '"' to account for the spaces but now it will not work for any file or folder. I also have the print statement "?" to make sure the code that should be sent to Robocopy is correct.
Can someone please tell me what I'm missing?
Code:
OPEN(1, "DeletedUser.csv", 2) ;Deleted User file created by
;DEBUG "ON" $X = ReadLine(1) While @Error=0 $Path = Left($X, InStrRev($X,"\")) ;DOS Path $Source = '"' + Left($X, InStrRev($X,"\")) + '"' + " " ;Source Path $Dest = '"' + "C:\Old" + Right($Path, Len($Path) - 2) + '"' + " " ;Destination Path $File = '"' + Right($X, Len($X) - Len($Path)) + '"' + " " ;File Name $Opti = " /Z /MOV"
;Show that the info being sent to robocopy is correct ? $Source ? $Dest ? $File
Shell "RoboCopy " + $Source + $Dest + $File + $Opti $X = ReadLine(1) Loop
Close(1) ;Close Deleted User file
Errors on test data on my computer. The code is correct in Kix looks the be correct but what is sent to the shell command for robocopy seems to be wrong.:
"C:\Data\Access\AHA\" "C:\Old\Data\Access\AHA\" "CISMN.LDB" ---------------------------------------------------------------------- ROBOCOPY v 1.96 : Robust File Copy for Windows NT ----------------------------------------------------------------------
Started : Sat Aug 31 23:23:20 2002
Source : C:\Data\Access\AHA" C:\Old\Data\Access\AHA"\ Dest : C:\Data\Archive\CISMN.LDB\ Files : *.* Options : *.* /MOV /Z /R:1000000 /W:30 ERROR 123 (0x0000007B) Accessing Source Directory C:\Data\Access\AHA" C:\Old\Data\Access\AHA"\ The filename, directory name, or volume label syntax is incorrect.
Thanks for your help,
Tom
_________________________
Tom Hagen Jr
Power comes from the Mind.
|
|
Top
|
|
|
|
#69595 - 2002-09-01 09:08 PM
Re: Archiving files using robocopy
|
Tom Hagen
Fresh Scripter
Registered: 2001-11-02
Posts: 7
Loc: Milwaukee, WI
|
les_ligetfalvy,
Thanks for you reply. I gave it a shot and did the following chnages:
OPEN(1, "DeletedUser.csv", 2) ;Deleted User file created by
;DEBUG "ON" $X = ReadLine(1) While @Error=0 $Path = Left($X, InStrRev($X,"\")) $Source = Chr(34) + Left($X, InStrRev($X,"\")) + Chr(34) + " " ;Source Path $Dest = Chr(34) + "C:\Old" + Right($Path, Len($Path) - 2) + Chr(34) + " " ;Destination Path $File = Chr(34) + Right($X, Len($X) - Len($Path)) + Chr(34) + " " ;File Name $Opti = " /Z /MOV"
? $Source ? $Dest ? $File $ShellCMD = "RoboCopy " + $Source + $Dest + $File + $Opti ? $ShellCMD Shell "%comspec% /c $ShellCMD" $X = ReadLine(1) Loop
Close(1) ;Close Deleted User file
I still got the same results. Any more suggestions?
_________________________
Tom Hagen Jr
Power comes from the Mind.
|
|
Top
|
|
|
|
#69596 - 2002-09-01 09:55 PM
Re: Archiving files using robocopy
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Please post the text of the what $X is equal to.
|
|
Top
|
|
|
|
#69597 - 2002-09-01 10:02 PM
Re: Archiving files using robocopy
|
Tom Hagen
Fresh Scripter
Registered: 2001-11-02
Posts: 7
Loc: Milwaukee, WI
|
Here is a copy of the csv file. Nothing fancy for the test. Have one of about 4000 lines so I made a test area to see how it worked. Each line is what $X eventually will be during the run.
C:\Data\Access\Final SMART Data Conversion.zip C:\Data\Access\Original Final SMART Data Conversion.zip C:\Data\Access\AHA\CISMN.LDB C:\Data\Access\AHA\CISMN.MDB
_________________________
Tom Hagen Jr
Power comes from the Mind.
|
|
Top
|
|
|
|
#69598 - 2002-09-01 10:24 PM
Re: Archiving files using robocopy
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Your code generates this string for $ShellCMD: code:
RoboCopy "C:\Data\Access\" "C:\Old\Data\Access\" "Final SMART Data Conversion.zip" /Z /MOV
Is that what you get? The problem is the way that robocopy is parsing the input. Drop the training "\" of each path. code:
$Path = Left($X, InStrRev($X,"\")-1) $Source = Chr(34) + Left($X, InStrRev($X,"\")-1) + Chr(34) + " " ;Source Path $Dest = Chr(34) + "C:\Old" + substr($Path, 3) + Chr(34) + " " ;Destination Path $File = Chr(34) + Right($X, Len($X) - Len($Path)-1) + Chr(34) + " " ;File Name $Opti = " /Z /MOV"
$ShellCMD = "RoboCopy " + $Source + $Dest + $File + $Opti
[ 01. September 2002, 22:50: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
#69599 - 2002-09-03 01:50 AM
Re: Archiving files using robocopy
|
Tom Hagen
Fresh Scripter
Registered: 2001-11-02
Posts: 7
Loc: Milwaukee, WI
|
Yes I found actually two problems one being the quotes and the other being the \. Now I just need to find the code to search folders and sub folders get the ownership of the files and if they are deleted users do this script. Basically looking for a way to replace the csv file that has to be modified.
code:
;***** Move Deleted users files based on DIRUSE.EXE utilty ;***** E:\Utilities\FileUt~1\diruse E:\Data /f:E:\Data\MIL01Detail.csv /s /t /v /d:w ;***** Modify the file removing the First Twp columns and all rows that you do not ;***** want to remove save the file as DeletedUser.csv
; $X is the line pulled from DeletedUser.csv ; $Path is the Path of the file ; $Source is the Path that robocopy uses for Source ; $Dest is the Path that robocopy uses for Destination ; $File is the Filename that robocopy uses ; $Opti is the Options that robocopy uses ; $ShellCMD is the command line that is passed out to run
;DEBUG "ON"
OPEN(1, "DeletedUser.csv", 2) ;Deleted User file created by DIRUSE.EXE
$X = ReadLine(1) While @Error=0
$Path = Left($X, InStrRev($X,"\") - 1) If INSTR ($Path, " ") = 0 $Source = $Path ;Source Path $Dest = "E:\Old" + Right($Path, Len($Path) - 2) ;Destination Path Else $Source = Chr(34) + $Path + Chr(34) ;Source Path $Dest = Chr(34) + "E:\Old" + Right($Path, Len($Path) - 2) + Chr(34) ;Destination Path EndIf
$FileName = Right($X, Len($X) - Len($Path) - 1) ;File Name If INSTR ($FileName, " ") = 0 $File = $FileName ;File Name Else $File = Chr(34) + $FileName + Chr(34) ;File Name EndIf
$Opti = "/R:3 /Z /MOVE" ;Options
$ShellCMD = "RoboCopy " + $Source + " " + $Dest + " " + $File + " " + $Opti
Shell "%comspec% /c $ShellCMD"
$X = ReadLine(1) Loop
Close(1) ;Close Deleted User file
Thanks for you help. Does anyone have suggestions on searching folders and finding out who owns each file? Been looking at scripts but have not found much.
_________________________
Tom Hagen Jr
Power comes from the Mind.
|
|
Top
|
|
|
|
#69600 - 2002-09-03 05:01 AM
Re: Archiving files using robocopy
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
I now have Perl code that can detect a deleted owner, but am struggling with ADsSecurity.GetSecurityDescriptor in order to get you a COM solution via KiXtart.
If a solution via COM doesn't materialize, I can provide you with a compiled Perl program that can recurse the file system and find files with deleted owners. [ 03. September 2002, 05:02: Message edited by: Howard Bullock ]
|
|
Top
|
|
|
|
Moderator: Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(mole)
and 1300 anonymous users online.
|
|
|