cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
bzanos
Level III

Copy File Function

I am using JMP 12.

I just want copy five csv files with different name from A folder and save it in B folder.

The A folder contains many csv files.

Using Copy File function (as below), I can only copy one file at a time.

I need to write below script five time to copy all five files 

 

 

Copy File( "C:\A\data1.csv", "C:\B\data1.csv" );
Copy File( "C:\A\data2.csv", "C:\B\data2.csv" );
Copy File( "C:\A\data3.csv", "C:\B\data3.csv" );
Copy File( "C:\A\data4.csv", "C:\B\data4.csv" );
Copy File( "C:\A\data5.csv", "C:\B\data5.csv" );

 

 

Is there a way to copy multiples files using one Copy File function?

or, is there other function/script that I can use to achieve this objective?

 

Thank you for your help.

2 ACCEPTED SOLUTIONS

Accepted Solutions
pmroz
Super User

Re: Copy File Function

for (i = 1, i <= 5, i++,
	file1 = evalinsert("C:\A\data^i^.csv");
	file2 = evalinsert("C:\B\data^i^.csv");
	copy file(file1, file2);
);

View solution in original post

Georg
Level VII

Re: Copy File Function

just another approach using a filelist or copy directory function,

however tested under JMP 15 with Windows, I have no JMP12.

 

Names Default To Here( 1 );

source_dir = "$TEMP\ADIR";
destination_dir = "$TEMP\BDIR";

// Prepare a directory and some files
If( !Directory Exists( source_dir ),
	Create Directory( source_dir )
);
Save Text File( source_dir || "\afile.txt", "afile content" );
Save Text File( source_dir || "\bfile.txt", "bfile content" );
Save Text File( source_dir || "\cfile.txt", "cfile content" );

// Generate list of files
file_list = Files In Directory( source_dir );

// Prepare destination directory
If( !Directory Exists( destination_dir ),
	Create Directory( destination_dir )
);

// Copy all files from list
For( i = 1, i <= N Items( file_list ), i++,
	Copy File( source_dir || "\" || file_list[i], destination_dir || "\" || file_list[i] )
);

// Copy directory
Copy Directory( source_dir, "$HOME", recursive( 1 ) );

// see results
Open( "$TEMP" );
Open( "$HOME" );

 

 

 

Georg

View solution in original post

3 REPLIES 3
pmroz
Super User

Re: Copy File Function

for (i = 1, i <= 5, i++,
	file1 = evalinsert("C:\A\data^i^.csv");
	file2 = evalinsert("C:\B\data^i^.csv");
	copy file(file1, file2);
);
Georg
Level VII

Re: Copy File Function

just another approach using a filelist or copy directory function,

however tested under JMP 15 with Windows, I have no JMP12.

 

Names Default To Here( 1 );

source_dir = "$TEMP\ADIR";
destination_dir = "$TEMP\BDIR";

// Prepare a directory and some files
If( !Directory Exists( source_dir ),
	Create Directory( source_dir )
);
Save Text File( source_dir || "\afile.txt", "afile content" );
Save Text File( source_dir || "\bfile.txt", "bfile content" );
Save Text File( source_dir || "\cfile.txt", "cfile content" );

// Generate list of files
file_list = Files In Directory( source_dir );

// Prepare destination directory
If( !Directory Exists( destination_dir ),
	Create Directory( destination_dir )
);

// Copy all files from list
For( i = 1, i <= N Items( file_list ), i++,
	Copy File( source_dir || "\" || file_list[i], destination_dir || "\" || file_list[i] )
);

// Copy directory
Copy Directory( source_dir, "$HOME", recursive( 1 ) );

// see results
Open( "$TEMP" );
Open( "$HOME" );

 

 

 

Georg
bzanos
Level III

Re: Copy File Function

Thank you.