//using Node.js
//npm i @types/node
import * as fs from 'fs'
import * as path from 'path'
let filePath = "file.txt"
let stats = fs.statSync(filePath)
//file size
let fileSize = stats.size
//file modification date
let dateChanges = stats.mtime
//file creation date
let creationDate = stats.birthtime
//can read, write, and execute
let canRWE = (stats.mode && fs.constants.S_IRWXU) ===
fs.constants.S_IRWXU
//file extension
let extension = path.extname(filePath)
//file name
let fileName = path.basename(filePath)
//file name without extension
let fileNameOnly = path.basename(filePath, extension)
//file directory
let fileDir = path.dirname(filePath)
console.log("fileSize is", fileSize, "bytes")
console.log("dateChanges is", dateChanges)
console.log("creationDate is", creationDate)
console.log("canRWE is", canRWE)
console.log("extension is", extension)
console.log("fileName is", fileName)
console.log("fileNameOnly is", fileNameOnly)
console.log("fileDir is", fileDir)