cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.
  • JMP will suspend normal business operations for our Rest and Recharge Day on Friday, October 2, 2026.
    Regular business hours will resume on Monday, October 5, 2026.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
natalie_
Level V

How to change file names?

Hi everyone,

Earlier I asked about how to extract files and it is working great!  Now I want to use these files, but the files are saved with ".pda-iv" (the file are coming from a parameter analyzer B1506).  In my script to open the file (ronFolder = Open(directory || deviceName || "\" || "RDS-ID.pda-iv");), I get an "Error with File: Path is Invalid" error.

Is there a way to change the name of the file?  For example, instead of RDS-ID.pda-iv, have it as RDS-ID.text.

Here is my code from how I extracted files:

/* 1) This script assumes all files within zipped files are text files.

   2) Make sure only zipped files are in the directory (ie., only B1506A data sheet zipped files)*/

directory = Pick Directory ();  //Choose directory where zipped folders are

filesInDirectory = Files In Directory(directory); //get list of files in directory

nFiles = N Items(filesInDirectory);  //get number of zip files in directory

For(i=1, i<=nFiles, i++,

           

      fileName = filesInDirectory[i];  //select ith file in list of

     

      /********Determine Device Name***********/

      pos = Contains(fileName, "_");      ///(example file name: GS66508T 65R6 #1_7-19-2016_11-04-28_AM.pda-ds)

      deviceName = left(fileName,pos-1); 

      /****************************************/

     

      /*******Create subdirectory for extracted files. 

            Make sure it is in a directory separate from all the zipped files*****/

      subDir = "C:\R&D Data\TSMC\E-HEMT\GS66508T\GS66508T 65R6 extractions\" || deviceName || "\";

      Create Directory(subDir);    

      /*************************************************************************/  

     

     

      za = Open(directory || fileName, zip); //Open zipped folder

      dirlist = za << dir;                            //Get list of files in zipped folder

      nZippedFiles = N Items(dirlist);          //get number of files in dirlist

     

      /*Step through dirlist and save each text file into the new sub directory*/

      for(k=1, k<=nZippedFiles , k++,          

            If(Right(dirlist[k],4) == ".txt",

                  text = za << read (dirlist[k]);

                  Save Text File(subDir || dirlist[k], text),);

     

      );

      /************************************************************************/

     

);

1 ACCEPTED SOLUTION

Accepted Solutions
natalie_
Level V

Re: How to change file names?

Got it!  It was really simple.  I am not sure why I got hung up on the Save Text File function.

/* 1) This script assumes all files within zipped files are text files.

   2) Make sure only zipped files are in the directory (ie., only B1506A data sheet zipped files)*/

directory = Pick Directory ();  //Choose directory where zipped folders are

filesInDirectory = Files In Directory(directory); //get list of files in directory

nFiles = N Items(filesInDirectory);  //get number of zip files in directory

For(i=1, i<=nFiles, i++,

  fileName = filesInDirectory;  //select ith file in list of

  /********Determine Device Name***********/

  pos = Contains(fileName, "_"); ///(example file name: GS66508T 65R6 #1_7-19-2016_11-04-28_AM.pda-ds)

  deviceName = left(fileName,pos-1);

  /****************************************/

  /*******Create subdirectory for extracted files. 

  Make sure it is in a directory separate from all the zipped files*****/

  subDir = "C:\R&D Data\TSMC\E-HEMT\GS66508T\GS66508T 65RG new extensions\" || deviceName || "\";

  Create Directory(subDir);

  /*************************************************************************/

  za = Open(directory || fileName, zip);  //Open zipped folder

  dirlist = za << dir; //Get list of files in zipped folder

  nZippedFiles = N Items(dirlist); //get number of files in dirlist

  /*Step through dirlist and save each text file into the new sub directory*/

  for(k=1, k<=nZippedFiles , k++,

  If(Right(dirlist,4) == ".txt",

  text = za << read (dirlist);

  fileNameZip = dirlist;

  pos = Contains(fileNameZip, ".");

  newFileName = Left(fileNameZip, pos-1);

  newFileName = newFileName || ".txt";

  Save Text File(subDir || newFileName, text),);

  );

  /************************************************************************/

);

View solution in original post

2 REPLIES 2
natalie_
Level V

Re: How to change file names?

Strange, I can open them manually but I can't get the script to work?

natalie_
Level V

Re: How to change file names?

Got it!  It was really simple.  I am not sure why I got hung up on the Save Text File function.

/* 1) This script assumes all files within zipped files are text files.

   2) Make sure only zipped files are in the directory (ie., only B1506A data sheet zipped files)*/

directory = Pick Directory ();  //Choose directory where zipped folders are

filesInDirectory = Files In Directory(directory); //get list of files in directory

nFiles = N Items(filesInDirectory);  //get number of zip files in directory

For(i=1, i<=nFiles, i++,

  fileName = filesInDirectory;  //select ith file in list of

  /********Determine Device Name***********/

  pos = Contains(fileName, "_"); ///(example file name: GS66508T 65R6 #1_7-19-2016_11-04-28_AM.pda-ds)

  deviceName = left(fileName,pos-1);

  /****************************************/

  /*******Create subdirectory for extracted files. 

  Make sure it is in a directory separate from all the zipped files*****/

  subDir = "C:\R&D Data\TSMC\E-HEMT\GS66508T\GS66508T 65RG new extensions\" || deviceName || "\";

  Create Directory(subDir);

  /*************************************************************************/

  za = Open(directory || fileName, zip);  //Open zipped folder

  dirlist = za << dir; //Get list of files in zipped folder

  nZippedFiles = N Items(dirlist); //get number of files in dirlist

  /*Step through dirlist and save each text file into the new sub directory*/

  for(k=1, k<=nZippedFiles , k++,

  If(Right(dirlist,4) == ".txt",

  text = za << read (dirlist);

  fileNameZip = dirlist;

  pos = Contains(fileNameZip, ".");

  newFileName = Left(fileNameZip, pos-1);

  newFileName = newFileName || ".txt";

  Save Text File(subDir || newFileName, text),);

  );

  /************************************************************************/

);

Recommended Articles