-
Notifications
You must be signed in to change notification settings - Fork 0
/
path.js
21 lines (14 loc) · 661 Bytes
/
path.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const path = require('path');
const test = '/Users/karan/Documents/Desktop/karan/be-b51/test.txt';
// get the directory name of the file
// console.log(path.dirname(test));
// get the filename with extension
// console.log(path.basename(test));
// get the extension alone
// console.log(path.extname(test));
// console.log('.' + test.split('.')[1])
// get the filename without the extension
console.log(path.basename(test, path.extname(test)));
// console.log(path.join('/Users/sathish/Documents/', 'Desktop/sathish', 'be-b51/test.txt'));
// appends teh filename with extension to the current home directory path
// console.log(path.resolve('test.txt'));