📁 File Module
The File module provides simple utilities for copying, moving, deleting, renaming files and retrieving basic file information.
Supported Features
- Copy Files
- Move Files
- Delete Files
- Rename Files
- Check File Existence
- Get File Size
- List Directory Contents
🚀 Quick Example
Copy a file to another location.
💻 Code
import allkitpy
allkitpy.file.copy(
"report.pdf",
"backup/report.pdf"
)
📤 Output
backup/
└── report.pdf
📚 Functions
📄 copy()
Copy a file from one location to another.
💻 Code
import allkitpy
allkitpy.file.copy(
"report.pdf",
"backup/report.pdf"
)
📤 Output
backup/
└── report.pdf
📂 move()
Move a file from one folder to another.
💻 Code
import allkitpy
allkitpy.file.move(
"report.pdf",
"archive/report.pdf"
)
📤 Output
archive/
└── report.pdf
🗑️ delete()
Delete a file from the file system.
💻 Code
import allkitpy
allkitpy.file.delete(
"old_report.pdf"
)
📤 Output
old_report.pdf deleted
✏️ rename()
Rename a file or change its location by providing a new filename or path.
💻 Code
import allkitpy
allkitpy.file.rename(
"draft.txt",
"final.txt"
)
📤 Output
final.txt
✅ exists()
Check whether a file or directory exists.
💻 Code
import allkitpy
result = allkitpy.file.exists(
"report.pdf"
)
print(result)
📤 Output
True
📏 size()
Return the size of a file in bytes.
💻 Code
import allkitpy
bytes_size = allkitpy.file.size(
"report.pdf"
)
print(bytes_size)
📤 Output
24576
📂 list_dir()
Return a list of files and folders inside a directory.
💻 Code
import allkitpy
items = allkitpy.file.list_dir(
"Documents"
)
print(items)
📤 Output
[
"report.pdf",
"notes.txt",
"images",
"backup"
]