MattX 0 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 ? Share this post Link to post Share on other sites
kristoff 0 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 Share this post Link to post Share on other sites
ezzetabi 3 Posted September 3, 2004 Or in AutoIt: FileMove ( "*.bmf", "*.pxf") Share this post Link to post Share on other sites
MattX 0 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 !! Share this post Link to post Share on other sites
ezzetabi 3 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 Share this post Link to post Share on other sites
MattX 0 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 !!! Share this post Link to post Share on other sites
ivan 1 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 Share this post Link to post Share on other sites
ezzetabi 3 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) Share this post Link to post Share on other sites
MattX 0 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 !! Share this post Link to post Share on other sites