: :
This message was edited by Tim3000 at 2005-7-11 13:26:29
: :
This message was edited by Tim3000 at 2005-7-11 13:24:58
: : : :
This message was edited by Tim3000 at 2005-7-11 12:58:26
: : : : HI ,
: : : :
: : : : I was trying to create an aplication that removes an specific character from a lot of diffent files in one map. but its not so easy as I thought it should be... perhaps someone from here know how to do it.. I try this using Delphi 2005 to make this clear
: : : :
: : : : FOLDER\index1.html
: : : : FOLDER\order1.html
: : : : FOLDER\mainpage1.html
: : : : FOLDER\page1.html
: : : :
: : : : So lets say from these filenames it should automaticly delete the character 1
: : : :
: : : : so it needs to do it automaticly and I can't name the NEW filenames in my code cause then my aplication would be useless ..I have an feeling that Renamefile function can't do this.. any ideas please? Thank you !
: : : :
: : : :
: : : You can use the FindFirst(), FindNext(), and FindClose() procedure to iterate through all the files in a directory. Because each for the files are basically text files, I would use a TStrings object to store the file's contents and StringReplace() to remove the characters.
: : :
: : :
: : Thank you for replying ,
: :
: : but with StringReplace function isn't that for replacing characters that are stored in the file? ,I need an function to delete an specific character of the Filenames .
: :
: :
: :
: :
: Then you should use the FindXXXX() procedures and a TStrings object to make a list of all the files within the folder. After you have such a list, you can use RenameFile() within a for-do loop to perform the renaming. StringReplace() can be used to remove the characters. Here is a pseudocode as a starting point:
:
: if FindFirst() = 0 then repeat
: Add filename to stringlist
: until FindNext()
: FindClose();
: for i := 0 to stringlist.Count-1 do
: RenameFile(stringlist[i], StringReplace());
:
:
Thanks a lot this helps :) now I can do it probably