09-10-2024 12:29 PM
Hi,
I have some files into a folder, files name are:
1
3
5
6
9
...
I need to programmatically rename files in a numerical sequence (ascending order):
1
2
3
4
5
...
Could you please show me some good examples to do it?
Thanks
09-10-2024 01:15 PM - edited 09-10-2024 01:18 PM
You can use the "Move" function. If you go in the order you've shown, there should not be any chance of overwriting. But, make sure you backup the files before you start playing with this function.
https://www.ni.com/docs/en-US/bundle/labview-api-ref/page/functions/move.html?srsltid=AfmBOooCONpnGB...
09-10-2024 01:26 PM
Dear Gregory,
Thanks but I have no idea how move function can help. Could you please attach a .vi example?
09-10-2024 01:32 PM
It's best if you try it first and then I can offer correction. You would use the original name as the "source path" and the new name as the "target path"
09-10-2024 01:48 PM
09-11-2024 02:49 AM
Hi,
I've tried it but it has problems with duplicated names. Anyway thanks for sharing it.
I've solved now with something like this. Files extensions are not included at the moment.
09-11-2024 03:03 AM - edited 09-11-2024 03:09 AM
Hi Mal,
@Mal123 wrote:
I've tried it but it has problems with duplicated names. Anyway thanks for sharing it.
I've solved now with something like this. Files extensions are not included at the moment.
@Mal123 wrote:
I have some files into a folder, files name are: 1 3 5 6 9 ...
I need to programmatically rename files in a numerical sequence (ascending order): 1 2 3 4 5 ...
09-11-2024 03:15 AM
Hi,
With the external list we obtain the number of files. Then the name of files during each iterations could change for this reason the internal list.
About corrispondence of numbers for my needs is not matter.
The last question is interesting... indeed I didn't try with more files >10!
09-11-2024 03:45 AM - edited 09-11-2024 03:46 AM
Hi Mal,
@Mal123 wrote:
About corrispondence of numbers for my needs is not matter.
So your algorithm is "not well defined": either define the algorithm completely - or implement some error handling to handle your FileMove errors!
@Mal123 wrote:
The last question is interesting... indeed I didn't try with more files >10!
So your algorithm is "not well defined": define the algorithm completely!
When defining an algorithm you need to consider such things - and it seems you missed this part at all…
09-11-2024 04:34 AM
Hi,
Replacing sort array with this useful string sort:
It works fine for my case: no matter file sequence, important names are in a numerical sequence.