Page 1 of 2 12>
Topic Options
#210024 - 2015-03-02 11:42 AM need help form the experts again
Buhli Offline
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:

 Code:
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
#210025 - 2015-03-02 07:12 PM Re: need help form the experts again [Re: Buhli]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
If you want to ignore sub-directories, you can change
 Code:
  If $File <> '.' And $File <> '..'
to
 Code:
If Not GetFileAttr($File) & 16
This will prevent the loop from processing if the file is any directory, including "." or "..".

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#210030 - 2015-03-04 03:19 PM Re: need help form the experts again [Re: Glenn Barnas]
Buhli Offline
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
#210032 - 2015-03-05 10:39 AM Re: need help form the experts again [Re: Buhli]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Hi Buhli,

had a shot at this, replaced the line with what Glenn suggested and it worked (of course)..



I guess you use a very outdated version of Kixtart. Can you confirm?


Attachments
350.png
Description:


_________________________



Top
#210039 - 2015-03-05 03:59 PM Re: need help form the experts again [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
While believing Glenn is almost always a good idea, this should be the better approach:

 Code:
  if not (getfileattr($File) & 16)					    ; if file is not a dir.


works as well as the other .. so I need to dig a bit into the code I guess:


Attachments
351.png
Description:


_________________________



Top
#210040 - 2015-03-05 04:18 PM Re: need help form the experts again [Re: Jochen]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Got it ..

corrected your initial code post to use a "proper" dir statement:

 Code:
$File = Dir($SPath)

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 ;\) )

 Code:
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 Offline
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 Offline
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
#210043 - 2015-03-06 03:59 PM Re: need help form the experts again [Re: Buhli]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
Sounds like a missing end if.
_________________________
!

download KiXnet

Top
#210056 - 2015-03-08 10:48 AM Re: need help form the experts again [Re: Lonkero]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Yeah, missing qoutes or something .. we need to see the whole thing.

@Buhli: mind posting the complete code? If there is anything speaking against it, you may as well pm me with it.
_________________________



Top
#210060 - 2015-03-09 07:24 PM Re: need help form the experts again [Re: Jochen]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Time to insert "Robocopy" idea here.. LOL

Robocopy can do some pretty amazing file copying routines for you. I would suggest at least looking into it to see if it might be a fit here. Aside from an easy one off file copies Robocopy is going to be better at the job and is built-in since Vista.

Top
#210071 - 2015-03-10 02:38 PM Re: need help form the experts again [Re: NTDOC]
Buhli Offline
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
#210072 - 2015-03-10 02:47 PM Re: need help form the experts again [Re: Buhli]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Wait - are you saying now that you want to move the ITN folder and contents and not ignore the subfolders? If so, that is a different process.

The code change I originally provided changed the part that looked at the results from DIR and ignored the "." and "..". It should now ignore any filename returned from DIR() that has the Directory attribute set.

If you indeed want to copy the subfolder and files, the logic will be different.

Please clarify whether you want to IGNORE or COPY the subfolders and we'll put something together that will work.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#210075 - 2015-03-10 03:49 PM Re: need help form the experts again [Re: Glenn Barnas]
Buhli Offline
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
#210077 - 2015-03-10 04:50 PM Re: need help form the experts again [Re: Buhli]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
you may send me the script (I'll delete all traces afterwards)
just click on my name,
<--- there, and choose "send PM" .. Code tags are working there as well as in posts ;\)
_________________________



Top
#210081 - 2015-03-11 02:22 AM Re: need help form the experts again [Re: Jochen]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Well then you need to also verify that all files were moved after you make the move. Any type of network loss during the process can potentially delete files.
Top
#210088 - 2015-03-11 10:59 AM Re: need help form the experts again [Re: NTDOC]
Buhli Offline
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
#210100 - 2015-03-11 04:30 PM Re: need help form the experts again [Re: Buhli]
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Ok, to complete the story for all for now ..

The simple solution was to change to:

 Code:
  if not ( getfileattr($SPath + $File) & 16 )        ; if file is not a dir.


A very D'oh moment for me as dir() of course returns only the name and not the path
_________________________



Top
#210108 - 2015-03-13 06:55 PM Re: need help form the experts again [Re: Jochen]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4396
Loc: New Jersey
Crap! I didn't remember that either or my original suggestion would have worked. \:\(
_________________________
Actually I am a Rocket Scientist! \:D

Top
#210109 - 2015-03-13 11:15 PM Re: need help form the experts again [Re: Glenn Barnas]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Members of the Alzheimer's group eh! \:D
Top
Page 1 of 2 12>


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.188 seconds in which 0.128 seconds were spent on a total of 16 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org