in the actual software development project, you may encounter the need to modify the suffix of the file ( For example, to modify the Doc format to docx format ) . This article provides a C Language implementation that modifies the file suffix and demonstrates the process of modifying the file suffix.
1. C Program Implementation
2. procedure for modifying suffixes
Step 1 :
in the local D disk, there is a call " Test " folder, under which there is a folder named " 123.doc " file, as shown in:
Create a new two folder under either folder, named old2new " ( ) and " ( Indicates that the new suffix is modified to the old suffix and c " changesuffix.exe " Copy to two folders.
Step 2 :
under these two folders, create a new file named " Config.ini " configuration file with each configuration entry in the file as follows:
[General]
; Converts the old suffix to a new suffix, or converts the new suffix to the old suffix, 1--old, new, 2--new
Old2newornew2old =
; Old file suffix (support configuration multiple, middle has; separate)
Oldsuffix = Doc;xls;ppt
; New file suffix (support configuration multiple, middle has; separate)
Newsuffix = Docx;xlsx;pptx
" old2new " old2newornew2old " set to 1 , " new2old " in the folder " old2newornew2old " set to 2
Step 3 :
in the " old2new " folder under new name " Update.bat " batch file with the contents of the file:
changesuffix "d:\\test" 0
among them, " d:\\test " is the path to the file where the suffix is to be modified.
in the " New2old " folder under new name " Update_restore.bat " batch file with the contents of the file:
Changesuffix "d:\\test" 1
among them, " d:\\test " is the path to the file where the suffix is to be modified.
" old2new " and the " New2old " the following files are stored under two folders:
Step 4 :
individually double-click " Update.bat " and the " Update_restore.bat " , the conversion function of old new and old suffix can be realized.
(I Weibo:http://weibo.com/zhouzxi?topnav=1&wvr=5, No.: 245924426, welcome attention!) )
C-language implementation for modifying file suffixes