Jump to content

File Name and Replace


MattX
 Share

Recommended Posts

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

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

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

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 by Larry
Link to comment
Share on other sites

And also a code help from me :ph34r:

$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

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...