Sign in to follow this  
Followers 0
dirty

Need help with For $var to $var

8 posts in this topic

Hey guys ! if anyone has time to help me with:

If $OS = "WIN_7" Then
    $UT3search1 = FileFindFirstFile ($UT3CompressedFilesVista & "\*.uz3")
    $UT3search2 = FileFindFirstFile ($UT3CompressedFilesVista & "\Characters\*.uz3")
    $UT3search3 = FileFindFirstFile ($UT3CompressedFilesVista & "\CustomChars\*.uz3")
    $UT3search4 = FileFindFirstFile ($UT3CompressedFilesVista & "\CustomMaps\*.uz3")
    $UT3search5 = FileFindFirstFile ($UT3CompressedFilesVista & "\Packages\*.uz3")
Endif
While 1
        $UT3searchreturn1 = FileFindNextFile ($UT3search1)

    $UT3searchreturn2 = FileFindNextFile ($UT3search2)

    $UT3searchreturn3 = FileFindNextFile ($UT3search3)

    $UT3searchreturn3 = FileFindNextFile ($UT3search4)

    $UT3searchreturn5 = FileFindNextFile ($UT3search5)
WEnd

    DirCreate ($UT3ResultPath)
    $UT3Moving = FileMove ($UT3CompressedFilesVista & $UT3searchreturn, $UT3ResultPath, 1)
    If $UT3Moving = 0 Then
        MsgBox (64,$MsgTitle, "Error moving file to output directory. " & $MSGERROR,"",$MainGUI)
        EndIf

Instead i need something to search only 1 destination but look into all its subdirectories, then move all .uz3 fiels found in all sunbirectories into $UT3ResultPath

I was thinking about having something to do with

For $i = "something" to $var = "something else"
Blah blah
Next

But i have no clue how does For work and how i can use it in my situation.

Can you guys help ?

Share this post


Link to post
Share on other sites



Again the answer is right in the help file. For..In.. should be fine in your case.

$files = _FileListToArray(...)
if @error ...
For $file In $Files
 ;process it
Next

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Again the answer is right in the help file. For..In.. should be fine in your case.

$files = _FileListToArray(...)
if @error ...
For $file In $Files
 ;process it
Next

Am sorry i dont understand the use of your example.

I tried to add it to my script but nothing.

Cant get it to search for files by extension .uz3

I tried

$UT3CompressedFilesVista = (@UserProfileDir & "\Documents\My Games\Unreal Tournament 3\UTGame\Unpublished\CookedPC\")
$files = _FileListToArray ($UT3CompressedFilesVista)
$string = _ArrayDisplay ($files,"title")

It returns 1rst line 4 and 4 folder names below

I dont understand how can i use this to have my files moved.

This is the loop which finds .uz3 files and moves them, but it only searching in one specified folder.

Is it possible for it to search in i specified folder and all its subfolders and ten move all found files to

$UT3CompressedFilesVista = (@UserProfileDir & "\Documents\My Games\Unreal Tournament 3\UTGame\Unpublished\CookedPC\")
$UT3search = FileFindFirstFile ($UT3CompressedFilesVista  & "*.uz3")

While 1
    $UT3searchreturn = FileFindNextFile ($UT3search)
If @error Then
    MsgBox(0,'','nothing found')
ExitLoop
    MsgBox (0,'',"$UT3search=" & $UT3search & @CRLF & " $UT3searchreturn=" & $UT3searchreturn)
Else
EndIf

    DirCreate (@DesktopDir & "\Result")
    $UT3Moving = FileMove ($UT3CompressedFilesVista & $UT3searchreturn, @DesktopDir & "\Result" , 1)
If $UT3Moving = 0 Then
    MsgBox (64,"", "Error moving file to output directory. ")
Else
    MsgBox(0,'','File moved')
EndIf
WEnd
Edited by dirty

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

UT3

that wouldn't be Ultimate Tournament 3 would it?

yes and i have jsut updated the code above so it would work without having rest of the $variables Edited by dirty

Share this post


Link to post
Share on other sites

UT3

that wouldn't be Ultimate Tournament 3 would it?

Yes it is. I simplified the code so who ever want to test it would be able to run it with minimal changes to make

$UT3CompressedFilesVista = (@UserProfileDir & "\Documents\My Games\Unreal Tournament 3\UTGame\Unpublished\CookedPC\")
$UT3search = FileFindFirstFile ($UT3CompressedFilesVista  & "*.uz3")

While 1
    $UT3searchreturn = FileFindNextFile ($UT3search)
If @error Then
    MsgBox(0,'','nothing found')
ExitLoop
    MsgBox (0,'',"$UT3search=" & $UT3search & @CRLF & " $UT3searchreturn=" & $UT3searchreturn)
Else
EndIf

    DirCreate (@DesktopDir & "\Result")
    $UT3Moving = FileMove ($UT3CompressedFilesVista & $UT3searchreturn, @DesktopDir & "\Result" , 1)
If $UT3Moving = 0 Then
    MsgBox (64,"", "Error moving file to output directory. ")
Else
    MsgBox(0,'','File moved')
EndIf
WEnd

It works find but its not searching sub directories and because it doesnt its not moving any files that are located in those sub directories.

Share this post


Link to post
Share on other sites

Use _ArrayDelete($Files, 0) to remove the first entry (number of entries).

You forgot to add "*" at the end of your file pattern. Yours returns only directories. You need both.

Anyway, you need a _recursive_ directory traversal. Search the forum for that, there are many ready to use, some of them recently posted.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

add "*" where ?

$UT3CompressedFilesVista = (@UserProfileDir & "\Documents\My Games\Unreal Tournament 3\UTGame\Unpublished\CookedPC\*")

here

$UT3searchreturn = FileFindNextFile ($UT3search& "*")

or here ?

$UT3Moving = FileMove ($UT3CompressedFilesVista & $UT3searchreturn & "*", @DesktopDir & "\Result" , 1)
Edited by dirty

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