File importing operations with extendscript
npm install kt-iobash
npm install kt-io
`
Basic Usage
Here are some examples of how to use KT-IO:
`typescript
// src/index.ts
import { IO } from "kt-io";
// Check if file exists
if (IO.fs.fileExists("data.txt")) {
// Read file content
const content = IO.fs.readFile("data.txt");
alert("File content: " + content);
}
// Write JSON data
const config = { theme: "dark", language: "en" };
IO.fs.writeJson("config.json", config);
// Copy files
IO.fs.copyFile("source.txt", "backup.txt");
`
File Operations
KT-IO supports various file operations:
`typescript
// File existence and metadata
const exists = IO.fs.fileExists("file.txt");
const size = IO.fs.getFileSize("file.txt");
const modified = IO.fs.getFileModifiedDate("file.txt");
// File operations
IO.fs.copyFile("source.txt", "dest.txt");
IO.fs.moveFile("old.txt", "new.txt");
IO.fs.deleteFile("temp.txt");
// Directory operations
IO.fs.createDirectory("logs", true); // recursive
const files = IO.fs.listFiles("data", /\.txt$/);
`
High-level Utilities
KT-IO provides high-level utilities for common tasks:
`typescript
// Create project structures from objects
const projectStructure = {
src: { components: {}, utils: {} },
docs: {},
tests: {},
};
IO.utils.createFolderTree(projectStructure, "/path/to/project");
`
Build Scripts
To transpile for ExtendScript, run:
`bash
npm run build
`
Documentation
For more detailed documentation, please refer to the specific README files in the docs folder:
- API Reference
- Examples
Test Files
You can find the test files in the src/tests` directory: