Easy way to rename file in blitz?
Blitz3D Forums/Blitz3D Programming/Easy way to rename file in blitz?
| ||
Hey, i'm looking for an easy way to rename a file, without having to open it and save it back to the harddisc, and delete the old one. I have alot of files, and i reckon doing this with so many files will not only put my hard disc under unnessesary strain, but also fragment it more. Any suggestions? |
| ||
Aside from possible AP{I stuff, which I am not sure even how to go about that), the simplest way I know in blitz is to use CopyFile and DeleteFile Since you are manipulating whole files at a time, and replacing them in the same places relatively, then defragmentation is apparwently minimal. Unless this is something specifivc to a blitz app you're working on, therer's a VERY handy tool which integrates into your Windows Shell context menu called "FileMenuTools" by Lopesoft http://www.lopesoft.com It's Free and has some invaluable features, including a BULK RENAME function! |
| ||
Surely fragmentation would occur though, as i'm opening a file, which i wouldn't delete till the new file was saved (in case of computer shutdown, and i possibly lose a file. Anyway, thanks for the suggestion. I found another awesome tool, File Renamer Basic, on download.com. Gives you the ability to bulk rename files, add numbers, change the case of the extension etc etc Just seems a bit of an oversight, not having a rename file option in blitz though. |
| ||
Yeah, soething that would have been very handy. Glad you found a solution though :) |
| ||
so hard to add this option a release new blitz3d version? |
| ||
...well, since someone already dredged up this old topic -CopyFile oldname, newname DeleteFile oldname EDIT: Stupid me, of course this doesn't actually address the problem that rewriting data to the disk is unnecessarily wasteful. Sorry. Rroff's solution is sensible though. Last edited 2011 |
| ||
Anyone would have thought it would be difficult to google "Windows API rename file" and create a decl for the function MoveFileEx from Kernel32.dll and implement it in your code... |
| ||
-.- |
| ||
lol if i knew how to do i would but im newbe in this field of dlls. purheps if someone guide me i would |
| ||
Save the following file to the folder "c:\program files\blitz3d\userlibs\" and name it "kernel32.decls" .lib "kernel32.dll" api_MoveFile% (lpExistingFileName$, lpNewFileName$) : "MoveFileA" Then, save the following program in a folder where there is also a file called "one.txt". api_MoveFile("one.txt", "two.txt") WaitKey When you run this program, it will rename "one.txt" to "two.txt". |
| ||
tnx ill try |
| ||
wow this is cool it works i just changeg the comman to renamefile_api i would like to know what is the priniciple of dll making then i will make more. cheers |
| ||
If you want to create your own dll's, look under the "Specs and Utils" tab above this forum. There is a subcat "User Libs Format" you can look into. For the default Windows DLLs, you could look into MSDN. It describes most of the possible Windows API calls: http://msdn.microsoft.com/en-us/library/aa383749(v=vs.85).aspx For instance MoveFile (found it under alphabetical order->M) http://msdn.microsoft.com/en-us/library/aa365239(v=vs.85).aspx |
| ||
great tnx |
| ||
I am officially saving this thread because those links from Warner are SOLID GODDAMN GOLD to me. 8D |