Detect existing, Size & Type
[ALL Syntax]
file mkdir "directory_name"
file delete "directory_name"
file delete -force "directory_name"
file delete "file_name"
file copy source-filename target-filename
file copy -force source-filename target-filename
file rename source-filename target-filename
file exists filename
file isdirectory filename
file isfile filename
file size filename
file type filename
Create a new directory
[Syntax]
- file mkdir "directory_name"
- Create a new directory and that name is "Folder-A".
file mkdir Folder-A
Delete a existing directory
[Syntax]
- file delete "directory_name"
- file delete -force "directory_name"
- file delete "file_name"
[Example Ideas]
- Delete a existing directory and that name is "Folder-A".
- Delete a existing directory, and sub-directory itself.
- Delete 4 existing files.
file delete Folder-A
file delete -force Folder-A
file delete File-A File-B /tmp/File-C /tmp/File-D
Copy
[Syntax]
- file copy source-filename target-filename
- file copy -force source-filename target-filename
[Example Ideas]
- Copy a file "file1.txt" to folder "/tmp".
- Copy a file "file1.txt' under folder "/worktmp" to folder "/tmp".
- Copy & replace a file if there is a same filename on folder "/tmp".
file copy file1.txt /tmp
file copy /worktmp/file1.exe /tmp
file copy -force /worktmp/file1.exe /tmp
Rename
[Syntax]
- file rename source-filename target-filename
[Example Ideas]
- Rename a file "file1.txt" to file2.txt on folder "/tmp".
- Rename a file "file1.txt' on folder "/worktmp" to file2.txt on folder "/tmp".
file rename file1.txt /tmp/file2.txt
file rename /worktmp/file1.exe /tmp/file2.txt
Detect existing file or directory
[Syntax]
- file exists filename
- file isdirectory filename
- file isfile filename
- file exists 判斷目錄 /tmp (or 檔案) 是否存在, 是的時候回傳 1, 否時就回傳0.
- file isdirectory 判斷檔案 /worktmp/file1.txt 的路徑是不是為目錄, 是的時候回傳 1, 否時就回傳0.
- file isfile 判斷檔案 /worktmp/file1.txt 的路徑是不是為檔案, 是的時候回傳 1, 否時就回傳0.
if { [file exists /tmp] } {puts "Exist"}
if { [file isdirectory /worktmp/file1.txt] } { puts "This is a directory" }
if { [file isfile /worktmp/file1.txt] } { puts "This is a file" }
[Syntax]
- file size filename
- file type filename
- file size 判斷檔案或目錄所使用的大小 bytes.
- file type 判斷檔案或目錄的類型, 回傳是 file, directory, characterSpecial, blockSpecial, fifo, link or socket.
file size /worktmp/file1.txt
file type /worktmp/file1.txt
沒有留言:
張貼留言