• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Create a New Folder and Coping file

Community Beginner ,
Apr 01, 2020 Apr 01, 2020

Copy link to clipboard

Copied

Dear Friends,
We try to Create a new folder and copy a ai files from one folder to another,
We achieved these process in macOS catalina by following code,

namespace fs = std::Filesystem;
fs::CreateDirectory(ai::FilePath folderPath );
fs::Copy(ai::FilePath srcPath, ai::FilePath destPath);

but, it not available in macOs High Sierra.
kindly tell any other alternate option for these process in macOS High Sierra.

Thanks & Regards

Jayashree.J

 

TOPICS
SDK

Views

251

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Apr 01, 2020 Apr 01, 2020

Copy link to clipboard

Copied

LATEST

Hi Jayashree,

if you like you could use ExtendScript's File and Folder objects to do that.

See into DOM documentation for methods and properties:

https://www.indesignjs.de/extendscriptAPI/illustrator21/#File.html

https://www.indesignjs.de/extendscriptAPI/illustrator21/#Folder.html

 

Below a code sample:

/*
	ExtendScript ( JavaScript ) code:
	
	1. Gets the user's Documents folder
	2. Writes all files of that folder with suffix *.ai to an array.
	3. Creates a new folder in the user's Documents folder.
	4. Loops the files array to copy every file to the new folder.
	
*/

var newFolderName = "NewFolderName";

// This defines a standard folder of the Folder object.
// The user's Documents folder
var sourceFolder = Folder.myDocuments;

// Get all AI files in the user's Documents folder:
var filesArray = sourceFolder.getFiles
(
	// FILTER FUNCTION:
	function( file )
	{
		if
		( 
			file instanceof File
			&&
			file.name.match(/\.ai$/)
			
		){ return true };
	}
);

// Definition of the new folder:
var newFolder = Folder( sourceFolder.fullName +"/"+ newFolderName );

// Test if that folder already exists. If yes, do nothing, if no, create it:
if( !newFolder.exists ){ newFolder.create() };

// Loop the filtered file array to copy every file in the array:
for( var n=0; n<filesArray.length; n++ )
{
	var currentFile = filesArray[n] ;
	var copyOfFile =  File( newFolder.fullName +"/"+ currentFile.name );
	
	// Do nothing if the file already exists:
	if( copyOfFile.exists ){ continue };
	currentFile.copy( copyOfFile );
};

 

The script could be executed by Adobe Illustrator.

 

Regards,
Uwe Laubender

( ACP )

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines