Page 1 of 1 1
Topic Options
#199080 - 2010-07-23 04:11 PM Help on Fonction DirPlus()
Arbracam Offline
Just in Town

Registered: 2008-04-21
Posts: 4
Hi all,

I would like to scan files in 2 directory and have in 2 variable, files of two directory (in the same loop)

So, I would use this like this

 Code:
 
Break on

$Files = dirplus("D:\kix\1")
$files2 = dirplus("D:\kix\2")

For Each $file In $files
For Each $? In $files2
	;$file are for files in directory "1"
	; I would like a variable for file in second directory without exit the loop.	

Next


Is it possible to get variable from two scan of directory in the same loop?
with Dirplus fonction or maybe another method....

Tx a lot by advance.


Edited by Arbracam (2010-07-23 04:11 PM)

Top
#199082 - 2010-07-23 04:48 PM Re: Help on Fonction DirPlus() [Re: Arbracam]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
your loop is a bit messed up. Missing a NEXT for example.

If you do it like this you will see every file for folder2 when you display each file from folder1. You could use a multidimensional array and store folder1 in the first dimension and folder2 in the second.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#199083 - 2010-07-23 05:05 PM Re: Help on Fonction DirPlus() [Re: Mart]
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Do you want to list the files from each directory one after the other? If so there are a couple of ways to do it:
 Code:
Break on

$Files = dirplus("D:\kix\1")
$files2 = dirplus("D:\kix\2")

For Each $file In Split(Join($files,@CRLF)+@CRLF+Join($files2,@CRLF),@CRLF)
    "File: "+$file+@CRLF
Next


or

 Code:
$asDirs="D:\kix\1","D:\kix\2"
For Each $sDir in $asDirs
   "Files from "+$sDir+":"+@CRLF
   For Each $sFile in DirPlus($sDir)
      " "+$sFile+@CRLF
   Next
   @CRLF
Next


If you want to list the folders side-by-side then this is a quick and dirty solution:
 Code:
Break ON

$sDir1="D:\KiX\1"
$sDir2="D:\KiX\2"

$asDir1=DirList($sDir1)
$asDir2=DirList($sDir2)

$iMostFiles=IIf(UBound($asDir1)>UBound($asDir2),UBound($asDir1),UBound($asDir2))

Redim Preserve $asDir1[$iMostFiles]
Redim Preserve $asDir2[$iMostFiles]

$sDir1+"  <->  "+$sDir2+@CRLF+@CRLF

For $i=0 To $iMostFiles
	$asDir1[$i]+"  <-> "+$asDir2[$i]+@CRLF
Next


If that's not what you want try explaining what you are trying to do so we can provide a better answer.

Top
#199091 - 2010-07-23 10:29 PM Re: Help on Fonction DirPlus() [Re: Richard H.]
Arbracam Offline
Just in Town

Registered: 2008-04-21
Posts: 4
Thx for your support Mart and Richard.

The last solution by Richard is what i seek.


I would like to list the folders side-by-side because :

I have 2 folders.
The first with 500 files in *.mov and the other with 500 same files but in *.mp4
And all files with *.mp4 have bad date modification attribute. (lost during conversion)

So, my idea was to list the first file in directory 1, get the date modification attribute of this file, and list the first file in directory 2, and apply the date attribute of first file in directory 1 and loop....

It's the reason this code seems to be good, but i don't know why, (Sorry' I'm newbieeee \:\) ) there is an error message : "array reference out of bounds --> "Redim Preserve $asDir1[$iMostFiles]"

 Code:
 
Code:
Break ON

$sDir1="D:\KiX\1"
$sDir2="D:\KiX\2"

$asDir1=DirList($sDir1)
$asDir2=DirList($sDir2)

$iMostFiles=IIf(UBound($asDir1)>UBound($asDir2),UBound($asDir1),UBound($asDir2))

Redim Preserve $asDir1[$iMostFiles]
Redim Preserve $asDir2[$iMostFiles]

$sDir1+"  <->  "+$sDir2+@CRLF+@CRLF

For $i=0 To $iMostFiles
	$asDir1[$i]+"  <-> "+$asDir2[$i]+@CRLF
Next



Edited by Arbracam (2010-07-23 10:30 PM)

Top
Page 1 of 1 1


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

Who's Online
0 registered and 2375 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.113 seconds in which 0.085 seconds were spent on a total of 13 queries. Zlib compression enabled.

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