MattX Posted September 3, 2004 Share Posted September 3, 2004 Need some advice on how I would go about coding a file name replacement on a load of file names. For example I have piped a list of file names I need to change: E:\Matt\as-paul\8H hmwork encyc page 10.bmf E:\Matt\as-paul\bass 9-12.bmf E:\Matt\as-paul\prepositions.bmf E:\Matt\as-paul\preps test.bmf E:\Matt\as-paul\subject and object.bmf E:\Matt\as-paul\Verb tense test, Y8.bmf E:\Matt\as-paul\vocab 8 retest.bmf E:\Matt\as-paul\y6 voc 1-3 test.bmf E:\Matt\as-paul\y6 voc test voc 1-3.bmf E:\Matt\as-paul\y7 princ. parts.bmf E:\Matt\as-paul\From Richard Woods\Year 6\Disce 4 test.bmf All these are .bmf files - I now need to script something which will change them all to .pxf files. I was thinking of using the stringreplace command - does anyone have any better ideas or a better way of doing this ? Link to comment Share on other sites More sharing options...
kristoff Posted September 3, 2004 Share Posted September 3, 2004 Need some advice on how I would go about coding a file name replacement on a load of file names. For example I have piped a list of file names I need to change: E:\Matt\as-paul\8H hmwork encyc page 10.bmf E:\Matt\as-paul\bass 9-12.bmf E:\Matt\as-paul\prepositions.bmf E:\Matt\as-paul\preps test.bmf E:\Matt\as-paul\subject and object.bmf E:\Matt\as-paul\Verb tense test, Y8.bmf E:\Matt\as-paul\vocab 8 retest.bmf E:\Matt\as-paul\y6 voc 1-3 test.bmf E:\Matt\as-paul\y6 voc test voc 1-3.bmf E:\Matt\as-paul\y7 princ. parts.bmf E:\Matt\as-paul\From Richard Woods\Year 6\Disce 4 test.bmf All these are .bmf files - I now need to script something which will change them all to .pxf files. I was thinking of using the stringreplace command - does anyone have any better ideas or a better way of doing this ? <{POST_SNAPBACK}>rename *.bmf *.pxf Link to comment Share on other sites More sharing options...
ezzetabi Posted September 3, 2004 Share Posted September 3, 2004 Or in AutoIt: FileMove ( "*.bmf", "*.pxf") Link to comment Share on other sites More sharing options...
MattX Posted September 3, 2004 Author Share Posted September 3, 2004 Or in AutoIt: FileMove ( "*.bmf", "*.pxf") <{POST_SNAPBACK}>Will that do all the files in the TXT file ? The txt file I supplied is nothing - I have around a few thousand that need changing !! Link to comment Share on other sites More sharing options...
ezzetabi Posted September 3, 2004 Share Posted September 3, 2004 Ops. I see the point. What about read the file, put it in a array and make a loop of file move? As origin you can use the $array[x] value, in the destination just string replace .bmf with .pxf Link to comment Share on other sites More sharing options...
MattX Posted September 3, 2004 Author Share Posted September 3, 2004 Ops. I see the point. What about read the file, put it in a array and make a loop of file move? As origin you can use the $array[x] value, in the destination just string replace .bmf with .pxf <{POST_SNAPBACK}>Wow - steep learning curve now - not used an array before - out comes the manual !!! Link to comment Share on other sites More sharing options...
ivan Posted September 4, 2004 Share Posted September 4, 2004 (edited) I've done this kind of thing hundreds of times. The last one generated html files from a txt file. i'm sure you could easily modify this kind of stuff to fit your needs. I hope it works for you. Global $A Global $Matter Namer() Filer() Exit Func Namer() For $Matter=1 to 8 step 1 $A=FileReadLine("Matter.txt",$Matter) Filer() Next EndFunc Func Filer() Local $B Local $C Local $Name For $C=1 to 6 step 1 $B=FileReadLine("Name.txt",$C) $Name=$A & $B &".html" FileWriteLine($Name,"") Next EndFunc Edited September 4, 2004 by Larry Think out of the boxGrabber: Yet another WinInfo tool_CSVLib (still alpha)Dynamic html in au3 Link to comment Share on other sites More sharing options...
ezzetabi Posted September 4, 2004 Share Posted September 4, 2004 And also a code help from me $c = 0 $handle = FileOpen('c:\listoffiletorename.txt') While 1 $c = $c + 1 $list = $list & @lf & FileReadLine($handle,$c) If @error exitloop Wend FileClose($handle) $list = StringSplit($list,@lf) For $c = 1 to $List[0] FileMove($list[$c],StringReplace($list[$c], ".bmf", ".pxf")) Sleep(10) Next ToolTip('Finished!') Sleep(5000) Link to comment Share on other sites More sharing options...
MattX Posted September 4, 2004 Author Share Posted September 4, 2004 Thanks a lot - I was starting to struggle with the code I had started - I shall look at both of these and go though it - they look quite different - Ivans looks quite complicated but I shall try and work out what its doing - many thanks again. This is gonna save me some time I can tell you !! Link to comment Share on other sites More sharing options...
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