renaming files
BlitzPlus Forums/BlitzPlus Programming/renaming files| 
 | ||
| Hi Brains ;-) How can I get BlitzPlus to rename files? There are batches of files that I have been backing up for years, all named for their creation date and subject. I now wish to change the date format which means renaming files. But I cannot, for some reason, find the command in B+ that does this. Would somebody be kind enough to point me to it? Thank you for your time and trouble :-) Julian ((.)(.)) OoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoO | 
| 
 | ||
| hmm, yes there isn't a command in BlitzPlus to do that.  You might have to call an appropriate windows API function instead ... as to which one .. sorry :-(  hmm just check my Delphi Win32 help and coulndn't find anything, weird! | 
| 
 | ||
| Function RenameFile%(path$, newpath$) CopyFile path$, newpath$ If FileType(newpath$) > 0 Then DeleteFile path$ Return True EndIf End Function | 
| 
 | ||
| Nice function. I realised that was an option but was trying to avoid it as it seemed inefficient when there must be a simpler way ... | 
| 
 | ||
| Thank you Andres for the function :-) I wasted all that time looking for a command :-/ Still ... Function RenameFile%(path$, newpath$) CopyFile path$, newpath$ If FileType(newpath$) > 0 Then DeleteFile path$ Return True EndIf End Function ... Problem solved (^_^) Julian (0_=) qpqpqpqpqpqpqpqpqpqpqpqpqp | 
| 
 | ||
| The only downside of this is if its a big file the user will need the space to 'rename' the file. I would go with the WinAPI call myself you could always call it using execfile: ExecFile "Rename "+path$+" "+newpath$ should do it. | 
| 
 | ||
| Shouldn't there be quotes around the paths? Many files and folders contain spaces. Or it must be converted to ******~1 ? | 
| 
 | ||
| well it's easy enough to put quotes round the paths, best to write a function to do it for reuse :-)  That's neat Execfile as it runs a dos command haha, but it'll work much quicker than copying. | 
| 
 | ||
| Wouldn't CreateProcess be better for it? |