This Python module provides the File
class, which represents a generic Windows file. It includes methods for retrieving information about the file, such as its type, name, size, and creation and modification dates.
To use this module, simply create an instance of the File
class, passing in the path to the file as a string argument:
from file import File file = File("C:\\path\\to\\file.txt")
You can then use the following methods and properties to retrieve information about the file:
Returns the file type of the file.
print(file.file_type) # "txt"
Returns the file name of the file.
print(file.file_name) # "file"
Returns True
if the file exists, False
otherwise.
print(file.exists) # True
Returns the file size in bytes. Raises a FileNotFoundError
if the file does not exist.
print(file.file_size) # 12345
Returns the creation date of the file as a string. Raises a FileNotFoundError
if the file does not exist.
print(file.creation_date) # "05/05/2023 10:30:15"
Returns the modification date of the file as a string. Raises a FileNotFoundError
if the file does not exist.
print(file.modification_date) # "05/05/2023 10:30:15"
Returns a string representation of the file.
print(repr(file)) # "File(C:\\path\\to\\file.txt)"
Returns a string representation of the file.
print(str(file)) # "C:\\path\\to\\file.txt"
Returns the file size in bytes. Raises a FileNotFoundError
if the file does not exist.
print(len(file)) # 12345
This Python module provides the RedStakeFile
class, which represents a Red Stake Surveyors file. It is a subclass of the File
class and provides additional methods and properties for working with Red Stake files.
To use this module, simply create an instance of the RedStakeFile
class, passing in the path to the file as a string argument:
from redstakefile import RedStakeFile file = RedStakeFile("C:\\path\\to\\file.dwg")
You can then use the following methods and properties to retrieve information about the file:
Returns the 8-digit file number of the Red Stake file. Reformats the number if necessary.
print(file.file_number) # "23040186"
Returns the year of the Red Stake file.
print(file.file_year) # "23"
Returns the month of the Red Stake file.
print(file.file_month) # "04"
Returns the destination directory of the Red Stake file. This is the directory to which the file should be moved based on its file type and file number.
print(file.file_destination_dir) # "\\server\dwg\23dwg\04"
This function relocates all Red Stake files in the specified source directory to their destination directories on the server.
from redstakefile import relocate_files relocate_files("C:\\path\\to\\source\\directory")
This module requires Python 3.x and the os
and shutil
modules, which are included in the Python standard library. It also requires the File
class from the file
module in the same repository.
This module is released under the MIT license. See LICENSE for more details.