Sign in to follow this  
Followers 0
jben

Creating a loop to loop through folder

1 post in this topic

Hi everyone. Can someone assist me in creating the following code into a loop so that I can include several folders..As in everywere I have mentioned ITEM2008 I would like to loop to include several folders. So the code will perform the action on folder ONE and then loop back and perform the action on folder TWO, and so on...

Not really sure how I could achieve this. Many Thanks

;------------------------------------------------------------------------------------------
; REMOVES ANY DATA CURRENTLY STORED IN THE SPECIFIED LOCATION
;------------------------------------------------------------------------------------------
DirRemove("C:\OUTPUT\ITEM2008", 1)
;------------------------------------------------------------------------------------------
; RENAMES CHILD ZIP
;------------------------------------------------------------------------------------------
$F_Array = __FldrListToArray("C:\EXTRCT_TEMP\ITEM2008\", 0);the rest of this string is detected in the code below.
For $I = 1 To Ubound($F_Array) -1
$targetDir = $F_Array[$I];this code states that the targetdir is the information provided via the $F_Array
;the purpose in this is because the $F_Array obtains the folder within the 29944M_10386 folder to complete
;the string, which is then used in the code below to rename the .zip file.
$aZipList = _FileListToArray($targetDir,"*.zip",0)

        If IsArray($aZipList) Then FileMove($targetDir & $aZipList[1], $targetDir & "DATA_CHILD.zip");renames zip
Next
;------------------------------------------------------------------------------------------
; EXTRACTS CHILD ZIP .NCP FILE
;------------------------------------------------------------------------------------------
$szZipFile = $targetDir &"DATA_CHILD.zip";this is the zip file to extract
$szDestDir = "C:\OUTPUT";this is the destination to extract the zip files

$aZipList = _ZipList2Array($szZipFile)
for $x =0 to UBound($aZipList)-1
    $file_type = StringLower(StringRight($aZipList[$x][1],4))
    If $file_type = ".ncp" Or $file_type = ".lcn" Then
      ConsoleWrite("Extracting:"&$aZipList[$x][1])
         $vResult = _ZipUnZipItem($szZipFile,$aZipList[$x][1],$szDestDir)
        ConsoleWrite(" -- "&_ZipFormatMessage($ZR_RECENT)&@lf)
        
    EndIf   
Next
;------------------------------------------------------------------------------------------
; MOVES FILES TO APPROPRIATE LOCATION. INCLUDES ERROR CHECKING AND NOTIFICAITON
;------------------------------------------------------------------------------------------
DirMove("C:\OUTPUT\MASTER\","C:\OUTPUT\ITEM2008\",1);moves MASTER Folder to specified dir

Share this post


Link to post
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0