Renaming .NC1 files

Hello. Please, help me!
how do I rename this file (att.) to what's inside it
i want to get: 52КМ_122_Уголок50X5_С235_14.nc1

122.nc1.txt (1.2 KB)

ST
** 122.nc1
  52КМ
  122
  9
  122
  C235
  14
  Уголок50X5
  L
    1330.00
      50.00
      50.00
       5.00
       5.00
       5.50
      3.770
      0.000
      0.000
     45.000
    -45.000
      0.000




AK
  v       0.00u      0.00       0.00       0.00       0.00       0.00       0.00
       1330.00       0.00       0.00       0.00       0.00       0.00       0.00
       1330.00      16.00       0.00       0.00       0.00       0.00       0.00
       1285.00      50.00       0.00       0.00       0.00       0.00       0.00
          0.00      50.00       0.00       0.00       0.00       0.00       0.00
          0.00       0.00       0.00       0.00       0.00       0.00       0.00
AK
  u       0.00o      0.00       0.00       0.00       0.00       0.00       0.00
       1330.00       0.00       0.00       0.00       0.00       0.00       0.00
       1330.00      50.00       0.00       0.00       0.00       0.00       0.00
         45.00      50.00       0.00       0.00       0.00       0.00       0.00
          0.00       5.00       0.00       0.00       0.00       0.00       0.00
          0.00       0.00       0.00       0.00       0.00       0.00       0.00
EN

You would need to write a rename script which opens the file and parses the contents.

If you search the forum for OpenTextFile and ReadLine there are examples of how to read text files in JScript and VBScript.

If it's just a case of selecting certain lines from the file and adding them to the filename then it should be fairly easy. I don't know what the file format is though, or if more complex parsing than that is needed to work with it.

i'm not familiar with any script, sorry.
its txt file has permanent structure, just a case of selecting certain lines from the file and adding them to the filename

I'm not sure if you want Line 4 or Line 6 for the filename, since they are both the same in your example, but here's a script you can adapt to your needs:

var fso = new ActiveXObject("Scripting.FileSystemObject")

function OnGetNewName(getNewNameData)
{
	var txt = fso.OpenTextFile(getNewNameData.item);
	if (txt.AtEndOfStream) return; txt.ReadLine();
	if (txt.AtEndOfStream) return; txt.ReadLine();
	if (txt.AtEndOfStream) return; var Line3 = txt.ReadLine();
	if (txt.AtEndOfStream) return; txt.ReadLine();
	if (txt.AtEndOfStream) return; txt.ReadLine();
	if (txt.AtEndOfStream) return; var Line6 = txt.ReadLine();
	if (txt.AtEndOfStream) return; var Line7 = txt.ReadLine();
	if (txt.AtEndOfStream) return; var Line8 = txt.ReadLine();
	if (txt.AtEndOfStream) return; var Line9 = txt.ReadLine();
	txt.Close();

	var filename = Line3 + Line6 + Line9 + Line7 + Line8;

	filename = filename.replace(/ +/g, "_");
	filename = filename.replace(/^_+/, "");
	filename = filename.replace(/_+$/, "");

	filename += getNewNameData.newname_ext_m;

	return filename;
}

Since the file isn't in a unicode format, and I'm using a different locale/codepage, the name characters look wrong in my screenshot, but they should be correct for you:

1 Like

You're great. million thanks

1 Like