#210024 - 2015-03-02 11:42 AM
need help form the experts again
|
Buhli
Fresh Scripter
Registered: 2012-09-24
Posts: 28
Loc: Berlin, Germany
|
Hello everyone, happy new year!
I have got a "small" problem. Glenn helped me out with creating a sorter for moving and copying files in the past.
It still works well and i love it. The problem now is, we needed to add a folder in the source direction, which we need for other stuff - "C:\etic\Kopie\ITN\"
The script still moves the files, but now it outputs the message with the new folder at the end. Is there an option to ignore the folder in the message?
Thank you for your help again, Buhli
Here is what i have running:
Break On
COLOR C+
:Loop ; loop over all
SLEEP 1
'Suche was...' ?
; -----------------------------------AG Coupons Übernahme Galileo Berlin------------------------------------------------------------
; Variablen RESET------------------------------------------------------------------------------------------------------------
Dim $FileDate ; File timestamp
Dim $FileYear ; Year of file timestamp
Dim $FileMonth ; Month of file timestamp
Dim $FileDay ; Day of file timestamp
Dim $aMonate ; Array of month names
Dim $SPAth, $DPath, $CPath ; Source, Copy and Destination paths
Dim $File ; Name of file being processed
Dim $DstDir ; Full destination path as created
$aMonate = Split('x,JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC', ',') ; name of month in Array
$SPath = 'C:\etic\Kopie\' ; Sorce dir
$DPath = 'T:\agcoupons\galileo\berlin\' ; target dir
$CPath = 'G:\MIR92\' ; copy dir
$File = Dir($SPath + '*.*') ; Variable file
; getting the 1. file
While Not @ERROR
If $File <> '.' And $File <> '..' ; if file is not a dir.
;'copy ' $SPath $File ? ; reading, what's going on
'move ' $SPath $File ? ; reading, what's going on
$FileDate = GetFileTime($SPath + $File)
$FileYear = SubStr($FileDate,1,4)
$FileMonth = $aMonate[Val(SubStr($FileDate, 6, 2))]
$FileDay = Right('0'+SubStr($FileDate,9,2),2)
$TypeFound = 0
$DstDir = $DPath + $FileYear + '\' + $FileMonth + '\' + $FileDay ; target dir
; creating the target dir if not exist
If Not Exist($DstDir)
'MD ' $DstDir ? ; for Debugging
MD $DstDir ; creating the target dir
EndIf
SLEEP 1 ; slowing down for reading
; move file into the target dir::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
SLEEP 1 ; slowing down for reading
Move $SPath + $File $DstDir ; enable executing
EndIf
$File = Dir() ; getting next file
Loop
GOTO "Loop"
|
Top
|
|
|
|
#210030 - 2015-03-04 03:19 PM
Re: need help form the experts again
[Re: Glenn Barnas]
|
Buhli
Fresh Scripter
Registered: 2012-09-24
Posts: 28
Loc: Berlin, Germany
|
Hello Glenn,
thank you very much for the quick reply! It does the work, but now the output is: move C:\etic\Kopie\. move C:\etic\Kopie\.. It also comes up when there is no file in the source-dir, exept the folder "ITN".
Do you have another great idea?
Thank you again, Buhli
|
Top
|
|
|
|
#210040 - 2015-03-05 04:18 PM
Re: need help form the experts again
[Re: Jochen]
|
Jochen
KiX Supporter
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
Got it ..
corrected your initial code post to use a "proper" dir statement:
It showed the behaviour you described in your last reply while using Glenns suggestion.
So, in conclusion: Use this one and you should be ok (I won't start the GOTO discussion today )
Break On
COLOR C+
:Loop ; loop over all
SLEEP 1
'Suche was...' ?
; -----------------------------------AG Coupons Übernahme Galileo Berlin------------------------------------------------------------
; Variablen RESET------------------------------------------------------------------------------------------------------------
Dim $FileDate ; File timestamp
Dim $FileYear ; Year of file timestamp
Dim $FileMonth ; Month of file timestamp
Dim $FileDay ; Day of file timestamp
Dim $aMonate ; Array of month names
Dim $SPAth, $DPath, $CPath ; Source, Copy and Destination paths
Dim $File ; Name of file being processed
Dim $DstDir ; Full destination path as created
$aMonate = Split('x,JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC', ',') ; name of month in Array
$SPath = 'C:\etic\Kopie\' ; Sorce dir
$DPath = 'T:\agcoupons\galileo\berlin\' ; target dir
$CPath = 'G:\MIR92\' ; copy dir
$File = Dir($SPath) ; Variable file
; getting the 1. file
While Not @ERROR
if not (getfileattr($File) & 16) ; if file is not a dir.
;'copy ' $SPath $File ? ; reading, what's going on
'move ' $SPath $File ? ; reading, what's going on
$FileDate = GetFileTime($SPath + $File)
$FileYear = SubStr($FileDate,1,4)
$FileMonth = $aMonate[Val(SubStr($FileDate, 6, 2))]
$FileDay = Right('0'+SubStr($FileDate,9,2),2)
$TypeFound = 0
$DstDir = $DPath + $FileYear + '\' + $FileMonth + '\' + $FileDay ; target dir
; creating the target dir if not exist
If Not Exist($DstDir)
'MD ' $DstDir ? ; for Debugging
MD $DstDir ; creating the target dir
EndIf
SLEEP 1 ; slowing down for reading
; move file into the target dir::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
SLEEP 1 ; slowing down for reading
Move $SPath + $File $DstDir ; enable executing
EndIf
$File = Dir() ; getting next file
Loop
GOTO "Loop"
_________________________
|
Top
|
|
|
|
#210041 - 2015-03-06 10:29 AM
Re: need help form the experts again
[Re: Jochen]
|
Buhli
Fresh Scripter
Registered: 2012-09-24
Posts: 28
Loc: Berlin, Germany
|
Cheers Jochen!
I will try it in an hour.
About the GOTO... there are 8 different sortings in this file we use, i just copied one into the page. It processes one by one, and at the end of all the sortings, it jumps back to the start-point.
I know, it could be faster and better, but my knowledge is very limited on this stuff and speed is not that important for us, it should just work. About the version of Kixtart, i have to confirm your guess - my boss... never touch a running system.
Thank you very much for now, i will report after testing.
Sorry about my English!
Best regards, Buhli
|
Top
|
|
|
|
#210042 - 2015-03-06 11:28 AM
Re: need help form the experts again
[Re: Buhli]
|
Buhli
Fresh Scripter
Registered: 2012-09-24
Posts: 28
Loc: Berlin, Germany
|
Hi Jochen,
it works just fine until there is no file in the dir for moving, except the ITN folder.
move C:\etic\Kopie\Test.txt move C:\etic\Kopie\Testing.txt move C:\etic\Kopie\ITN
Strange,
Buhli
|
Top
|
|
|
|
#210071 - 2015-03-10 02:38 PM
Re: need help form the experts again
[Re: NTDOC]
|
Buhli
Fresh Scripter
Registered: 2012-09-24
Posts: 28
Loc: Berlin, Germany
|
Hi all, sorry for the late reply, but i had some issues with the forum, i can't enter the topic. Works now.
@NTDOC, i know about robocopy, but our choice was Kixtart.
@Jochen, my boss don't let me do it, maybe a pm would be ok. Maybe i said it wrong, it doesn't move the folder "ITN", it just gives out the message.
best regards, Buhli
|
Top
|
|
|
|
#210075 - 2015-03-10 03:49 PM
Re: need help form the experts again
[Re: Glenn Barnas]
|
Buhli
Fresh Scripter
Registered: 2012-09-24
Posts: 28
Loc: Berlin, Germany
|
Sorry if i did some errors in my expression.
It should move all files in the source-dir except the folder "TIN" into the target-dir. (it don't moves the folder, but the output says it does) We need the folder "ITN" for a different sorting, if there is a file in ITN, move into bla-dir.
Hope my English is good enough gents and sorry for the trouble. Buhli
|
Top
|
|
|
|
#210088 - 2015-03-11 10:59 AM
Re: need help form the experts again
[Re: NTDOC]
|
Buhli
Fresh Scripter
Registered: 2012-09-24
Posts: 28
Loc: Berlin, Germany
|
Yep, true. Thats why i normal run the copy command as well, but so far no misses.
|
Top
|
|
|
|
#210109 - 2015-03-13 11:15 PM
Re: need help form the experts again
[Re: Glenn Barnas]
|
NTDOC
Administrator
Registered: 2000-07-28
Posts: 11623
Loc: CA
|
Members of the Alzheimer's group eh!
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 248 anonymous users online.
|
|
|