SOLVED: Getting a File Number Integer from the @pdg_filename string?

   1294   1   0
User Avatar
Member
42 posts
Joined: Dec. 2016
Offline
Hello

I have a folder with non-sequentially numbered files, for example:

Filename_1.exr
Filename_10.exr
Filename_126.exr
Filename_8694.exr
Filename_90223.exr

I need to strip "Filename_" and convert the remaining numbers from string to int.

I can achieve this in a vex wrangle using this simple code:

s@filename = @sourcefilename[9:];
- Removes the first 9 characters

i@filenumber = atoi(@filename);
- converts the string to integer


In TOPS I cannot find a way to achieve this... I tried to do it in Attribute Create using this in the integer attribute field:

atoi(@filename[9:])
but it returns an error.

Any advice as to how this issue can be resolved or approached in a different way is much appreciated
Edited by polimpiado - Oct. 11, 2021 12:44:42
User Avatar
Member
42 posts
Joined: Dec. 2016
Offline
Solution is to use Attribute from String, Add:
Filename_{filenumber}
to match input file pattern
  • Quick Links