I have 1 Edit field where user is supposed to enter a mask for example:
...
I have a button and If user presses it then for example in Memo1 a line will be added like this
@Rik I simply kept his/her order...The point is that the order (and input) is given by a random user and would be different each time. You can't expect it to be the same order as given by the example.
I have 1 Edit field where user is supposed to enter a mask for example:
...
I have a button and If user presses it then for example in Memo1 a line will be added like this
so the ouput string would like like this in my exampleOption 1 mentioned in my answer will do exactly what you want.
TOMEK_TOMEK_DOM_TOMEK
so the ouput string would like like this in my exampleOption 1 mentioned in my answer will do exactly what you want.
TOMEK_TOMEK_DOM_TOMEK
If you really want index before 1, 2 etc then you can change this
'%' + I.ToString + '%'
into this
'%index' + I.ToString + '%'
1 2 1 4 3 2 3 1
Ok. So I managed to create program which can rename files using the folder structure with possibility to mix them in the way that user wants... For example:So after running those files through my program with this patter %folder5%_%folder4%_%folder3%_%folder2%_%folder1%, the files will be named like this:
C:\MainFolder\30\0\23\943\1\TextFileA.txt C:\MainFolder\30\0\23\943\1\TextFile033.txt C:\MainFolder\30\0\23\943\1\TextFile03a.txt C:\MainFolder\30\0\23\943\1\TextFile0341.txt C:\MainFolder\35\123\23\943\1\TextFileB.txt C:\MainFolder\35\123\23\943\1\TextFileGF.txt C:\MainFolder\35\123\23\943\1\TextFileBK.txt C:\MainFolder\35\123\23\943\1\TextFileOD.txt
C:\MainFolder\30\0\23\943\1\30_0_23_943_1_0001.txt C:\MainFolder\30\0\23\943\1\30_0_23_943_1_0002.txt C:\MainFolder\30\0\23\943\1\30_0_23_943_1_0003.txt. C:\MainFolder\30\0\23\943\1\30_0_23_943_1_0004.txt C:\MainFolder\35\123\23\943\1\35_123_23_943_1_0001.txt C:\MainFolder\35\123\23\943\1\35_123_23_943_1_0002.txt C:\MainFolder\35\123\23\943\1\35_123_23_943_1_0003.txt C:\MainFolder\35\123\23\943\1\35_123_23_943_1_0004.txt
number at the end of the file, for now is hard coded and will be always added.
I would like to give user a possibility to decide if he wants this counter and WHERE he wants it (ofcourse he wants it :P! otherwise files will be overwritten :P). But hey.. I want to do something like this.
User enters a pattern like this:
%folder5%_%folder4%_%folder3%_%folder2%_%folder1%_%COUNTER%
Now I'm using solution that RVK provided and its good. But it uses StringReplace. So how can I add more masks to Pattern? For example %COUNTER% to add counter or %EXT% to add extension of the file.
[/s]
What you are doing is simply putting in a variable name that will translate to a index number of course.
and to do so effectively you should write parser for it that toggles a Boolean type to indicate if you
are between a pair of &...& and if so, accumulate a String from that. each time you hit a "&" you
toggle the Toggle Flag..
If inputChar = '&' Then ToggleFlag := Not ToggleFlag;
Then while you are concating the main string, you test for this flag..
if flag is TRUE then you are concating a search string, if not, then you are concating the
main string..
each time you toggle this flag, you need to test it, if its false after a toggle this means you just
finished a build of a search string, in which case you now use that results to search the list..
etc..
if you need an example I can provide one..