/dev/null Posted February 2, 2007 Posted February 2, 2007 (edited) Hi,here is my contribution to a reccuring problem. Ever wanted to change something in, or do something with a lot of files? Hereis my solution. _FileChangeRecursive()This functions finds files based on a given pattern (like FileFindFirstFile),while it walks recursively through a given directory tree (up to a givenrecursion level). Then it takes the files that match the pattern, andpass them to a "worker function", one by one. That worker function actually does the job of "changing" the files.Sample #1Task: Rename all files *.au3 -> *.au4Function Call: $retval = _FileChangeRecursive("C:\temp\autoit","*.au3",-1,"_RenameFile",".au4")oÝ÷ Ùµ¨®G«~éܶ*'ý¶®¶s`¦gVæ2õ&VæÖTfÆRb33c¶fÆWFÂb33c¶WFVç7Föâ Æö6Âb33c·'G2Ò7G&æu7ÆBb33c¶fÆWFÂgV÷C²âgV÷C² Æö6Âb33c¶æWwFÒgV÷C²gV÷C° f÷"b33c¶âÒFòb33c·'G5³ÒÓ b33c¶æWwFf׳Òb33c·'G5²b33c¶åÐ æW@ fÆTÖ÷fRb33c¶fÆWFÂb33c¶æWwFfײb33c¶WFVç7Föâ¦VæFgVæ0 oÝ÷ Ù´^ÛöÛM«$ý³æiÉ.¦ÚWâë-¡Ø}êÞ×bç-¢¼©ë®÷çè׫²ÚîrÛ«y±nËb¢p_Ûjëh×6$retval = _FileChangeRecursive("C:\temp\autoit","*.au3",-1,"_BackupFile","C:\temp\autoit","c:\temp\backup")oÝ÷ Ùµ¨®G«~éܶ*'ý¶®¶s`¦gVæ2ô&6·WfÆRb33c¶fÆWFÂb33c¶&6WFÂb33c¶&6·WföÆFW" Æö6Âb33c·&VÇFÒ7G&æu&WÆ6Rb33c¶fÆWFÂb33c¶&6WFÂgV÷C²gV÷C² fÆT6÷b33c¶fÆWFÂb33c¶&6·WföÆFW"fײb33c·&VÇFó¦VæFgVæ0As you can see, you'll have to pass the name of the worker function andall function parameters for the worker (up to 5 parameters arepossible). The benefit of _FileChangeRecursive()is that you have one function thatsearches the files recursively and you can write several "worker" functionswithout the need to change a single line of _FileChangeRecursive().For more samples see the attached files. Documentation is in the function code itself!Have fun!CheersKurt_FileChangeRecursive.au3_FileChangeRecursive_Samples.au3 Edited February 2, 2007 by /dev/null __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
Valik Posted February 3, 2007 Posted February 3, 2007 Brilliant. Somebody actually using Call() for the purpose I re-designed it for.
/dev/null Posted February 3, 2007 Author Posted February 3, 2007 Brilliant. Somebody actually using Call() for the purpose I re-designed it for.Thanks! __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
_Kurt Posted February 3, 2007 Posted February 3, 2007 This would be perfect for my recently posted Ipod Music Transfer. Too bad I'm kind of lazy, I might add it in sooner or later. Good Job! Kurt Awaiting Diablo III..
Moderators SmOke_N Posted February 9, 2007 Moderators Posted February 9, 2007 Hi everybody!@ /dev/null:I like this UDF a lot, thanks for sharing it. I'm PMing you some commentsalcThe MVPs can only receive PMs from someone that has over 250 posts or has been on the board for at least 6 months. You're best bet is to PM Valik, he will give you the proper reply based on the relevance and intelligence of your PM. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
Valik Posted February 9, 2007 Posted February 9, 2007 Don't encourage people to PM me. I get enough crap as is. Encourage people to post in public threads so we can all have a go at them.
/dev/null Posted February 9, 2007 Author Posted February 9, 2007 The MVPs can only receive PMs from someone that has over 250 posts or has been on the board for at least 6 months. You're best bet is to PM Valik, he will give you the proper reply based on the relevance and intelligence of your PM. Anyway, too late.... __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
Moderators SmOke_N Posted February 9, 2007 Moderators Posted February 9, 2007 Don't encourage people to PM me. I get enough crap as is. Encourage people to post in public threads so we can all have a go at them.I would have thought that to be discouragement to PM anyone... ... but I agree whole heartedly!! Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
/dev/null Posted February 9, 2007 Author Posted February 9, 2007 @ /dev/null: What means too late?never mind, all O.K. It will take some time to answer your PM, as it's a bit "lengthy". BTW can you post or PM the modifications you have made? Thanks!CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
/dev/null Posted February 9, 2007 Author Posted February 9, 2007 Ok, but I need to finished it and polish the look. Give me some time, cause right now my boss is standing behind me and asking for some results he is expecting. I'll try to post it today, but don't sure I'll have time, may be I'll have to post on Monday, I don't have Internet at home. Ok?Just in case, happy weekend for everybodyO.K. Have a nice weekend! __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
/dev/null Posted February 12, 2007 Author Posted February 12, 2007 Hi alc, as I posted the code here, your are free to use and modify based on your needs. So, go ahead and change whatever you like... Cheers Kurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
Krem Posted March 8, 2007 Posted March 8, 2007 (edited) Hi and thanks a lot for your script. I'm using it and I really like it. that's a great job you have done. I wish to have other functionnalities : => choose folder / file or Folder+file => an array of file exceptions to work on *.* but not *.zip nor *.rar etc. I made a little function to be used with your script. please feel free to used it. any comment/suggestion are welcome. CODE ; Compact an access database ; required At least MDAC 2.1 ; No access installation is needed ; ; $Destination must be different from $Source ; ; $Replace ; 0 => keep $Source and $Destination file ; 1 => replace $Source with $Destination ; keep $Destination file ; 2 => replace $Source with $Destination ; remove $Destination file ; func _CompactMDB($Source,$Destination, $Replace=0) If FileExists($Source) Then if FileExists($Destination)=0 Then $oMDB = ObjCreate("JRO.JetEngine") If IsObj($oMDB) Then $oMDB.CompactDatabase( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $Source, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $Destination) EndIf Switch $Replace case 1 filecopy( $Destination, $Source, 1+8) case 2 filemove( $Destination, $Source, 1+8) EndSwitch EndIf EndIf endFunc Edited March 8, 2007 by Krem
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now