Macbook: How to create a new text file in Finder (step by step)
ใน Windows ถ้าเราจะสร้างไฟล์ใหม่ ก็แค่ right click > new file
ได้เลย
แต่ใน Mac มันทำไม่ได้นี่สิ, มีแต่ New Folder แต่ไม่มี New File
วิธีที่ programmer ใช้คือ touch newfile.txt
ผ่าน command line แต่สำหรับ users ทั่วไปที่ไม่ถนัด มาลอง configure Mac กันดีกว่าคับ
10 ขั้นตอนสร้าง New Text File in Finder
- เปิด Automator > File > New
2. เลือก Quick Action
3. เลือก Workflow receives = no input in Finder
4. ต่อไปให้พิมพ์คำว่า javas เพื่อเรียกโครง function js ขึ้นมา
5. พิมพ์ code js ชุดนี้เข้าไป
function run(input, parameters) {
var finder = Application('Finder');
finder.includeStandardAdditions = true;
var currentPath = decodeURI(finder.windows[0].target().url().slice(7));
return currentPath;
}
และ cmd + s เพื่อ save ในชื่อ New Text File
6. ให้พิมพ์ set va
และ drage เพื่อสร้างโครงของ variable ดังรูป
7. สร้าง variable ชื่อว่า currentPath
ดังรูป
8. สร้างส่วนของ New Text File
9. เนื่องจาก New File ที่ได้จะมีข้อความของ currentPath อยู่ด้านในด้วย เราจึงต้องเพิ่ม js พร้อมกับ ignore input
10. ไฟล์ js ที่สร้างขึ้นมาใหม่ ให้ return empty string เรียบร้อยแล้วก้อ Save อีกรอบ
จบแล้วใน 10 ขั้นตอนสร้าง New Text File ใน Finder นะคับ ส่วนวิธีการเรียกใช้ทำได้ 2 แบบคือ
- เรียกผ่าน
Finder > Services > New Text File
ได้เลย (แต่จะไม่ค่อยสะดวกเท่าไหร่นัก)
- สร้าง Shortcut มาเรียกดีกว่า โดยเข้าไปที่
Keyboard > Shortcuts > Services > มองหา New Text File
แล้วพบกันใหม่คับ