Raised This Month: $ Target: $400
 0% 

Rename files to .old...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
avlisrotiv
Member
Join Date: May 2010
Old 08-10-2010 , 10:48   Rename files to .old...
Reply With Quote #1

Hello!
I have a question... Is it possible to rename a file server by script?
For example: Before you edit the "lol.cfg" create a backup of this file, the "lol.cfg.old". And then another script, delete the "lol.cfg" and rename the "lol.cfg.old" to "lol.cfg" to "restore" the backup...

(Sorry for my bad English...)
Is it possible?

Or ..: Any alternative contrary command: WriteFileLine?
There is something like: DelFileLine ?
... to delete a line in a file?

Last edited by avlisrotiv; 08-10-2010 at 11:15.
avlisrotiv is offline
naven
Veteran Member
Join Date: Jun 2008
Location: Poland, Cieszyn
Old 08-10-2010 , 11:23   Re: Rename files to .old...
Reply With Quote #2

You can take .cfg content, then make file.cfg.old with content and delete the old file.
__________________
naven.com.pl
"At the end of the day, there are always going to be mental disorders and people who cause violence for no other reason than the fact that they're fucked up and lost. And all we can do is try to learn from it." Corey Taylor.
naven is offline
avlisrotiv
Member
Join Date: May 2010
Old 08-10-2010 , 12:32   Re: Rename files to .old...
Reply With Quote #3

Quote:
Originally Posted by N A V E N View Post
You can take .cfg content, then make file.cfg.old with content and delete the old file.
Ok... Commands please...?
avlisrotiv is offline
rotab
Junior Member
Join Date: Dec 2005
Location: Sweden
Old 08-10-2010 , 13:08   Re: Rename files to .old...
Reply With Quote #4

OpenFile, ReadFile, WriteFile

DeleteFile, RenameFile
rotab is offline
avlisrotiv
Member
Join Date: May 2010
Old 08-10-2010 , 14:00   Re: Rename files to .old...
Reply With Quote #5

Quote:
Originally Posted by rotab View Post
OpenFile, ReadFile, WriteFile

DeleteFile, RenameFile
Tnk... You can make "some explication"? Like...

To edit is:
Code:
    new String:szFile[256];
    BuildPath(Path_SM, szFile, sizeof(szFile), "lol.cfg");
    new Handle:hFile = OpenFile(szFile, "at");
    WriteFileLine(hFile, "AHAHAH whing like taht");
    CloseHandle(hFile);
And to delete and rename?
You can post some example please?
avlisrotiv is offline
avlisrotiv
Member
Join Date: May 2010
Old 08-11-2010 , 08:08   Re: Rename files to .old...
Reply With Quote #6

You can post some example please?
avlisrotiv is offline
rotab
Junior Member
Join Date: Dec 2005
Location: Sweden
Old 08-11-2010 , 12:14   Re: Rename files to .old...
Reply With Quote #7

Deleting
PHP Code:
DeleteFile(szFile); 
Renaming
PHP Code:
    new String:szFile[256];
    new 
String:szFileOld[256];
    
BuildPath(Path_SMszFilesizeof(szFile), "lol.cfg");
    
BuildPath(Path_SMszFileOldsizeof(szFileOld), "lol.cfg.old");
    
//.cfg to .cfg.old
    
RenameFile(szFileOldszFile);
    
    
//cfg.old to .cfg
    
RenameFile(szFileszFileOld); 
Should work.. Thunderstorm inc. gotta goooo
rotab is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:30.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode