rofunc.utils.oslab.dir_process
#
1. Module Contents#
1.1. Functions#
Create the directory if it does not exist. |
|
Get the absolute path of each file in the directory. |
|
Delete the appointed files in the directory. |
|
Rename the appointed files from source_file_list to target_file_list. |
|
Copy the appointed files from src_dir to dst_dir. |
1.2. API#
- rofunc.utils.oslab.dir_process.create_dir(path, local_verbose=False)[source]#
Create the directory if it does not exist.
Example:
>>> import rofunc as rf >>> rf.oslab.create_dir('/home/ubuntu/Github/Rofunc/examples/data/felt/trial_1', local_verbose=True)
- Parameters:
path – the path of the directory
local_verbose – if True, print the message
- Returns:
- rofunc.utils.oslab.dir_process.list_absl_path(dir, recursive=False, prefix=None, suffix=None)[source]#
Get the absolute path of each file in the directory.
Example:
>>> list_absl_path('/home/ubuntu/Github/Rofunc/examples/data/felt', recursive=True) ['/home/ubuntu/Github/Rofunc/examples/data/felt/trial_1/mocap_hand_rigid.npy', '/home/ubuntu/Github/Rofunc/examples/data/felt/trial_1/mocap_object_rigid.npy', ...]
- Parameters:
dir – directory path
recursive – if True, list the files in the subdirectories as well
prefix – if not None, only list the files with the appointed prefix
suffix – if not None, only list the files with the appointed suffix
- Returns:
list
- rofunc.utils.oslab.dir_process.delete_files(dir, file_list_to_delete, recursive=False)[source]#
Delete the appointed files in the directory.
Example:
>>> import rofunc as rf >>> rf.utils.delete_files('/home/ubuntu/Github/Rofunc/examples/data/felt', ['desktop.ini'], recursive=True)
- Parameters:
dir – directory path
file_list_to_delete – the list of file names need to be deleted, need suffix
recursive – if True, delete the files in the subdirectories as well
- Returns:
None
- rofunc.utils.oslab.dir_process.rename_files(dir, src_file_list=None, dst_file_list=None, recursive=False)[source]#
Rename the appointed files from source_file_list to target_file_list.
Example:
>>> import rofunc as rf >>> rf.utils.rename_files('/home/ubuntu/Github/Rofunc/examples/data/felt', ... source_file_list=['wiping_spiral_mocap_hand.csv', 'wiping_spiral_mocap_hand_rigid.csv'], ... target_file_list=['mocap_hand.csv', 'mocap_hand_rigid.csv', 'mocap_object.csv'], ... recursive=True)
- Parameters:
dir – directory path
src_file_list – the list of file names need to be renamed, need suffix
dst_file_list – the list of file names need to be renamed to, need suffix
recursive – if True, rename the files in the subdirectories as well
- Returns:
None
- rofunc.utils.oslab.dir_process.shutil_files(files, src_dir, dst_dir)[source]#
Copy the appointed files from src_dir to dst_dir.
Example:
>>> import rofunc as rf >>> rf.utils.shutil_files(['mocap_hand.csv', 'mocap_hand_rigid.csv', 'mocap_object.csv'], ... src_dir='/home/ubuntu/Github/Rofunc/examples/data/felt/trial_1', ... dst_dir='/home/ubuntu/Github/Rofunc/examples/data/felt/trial_2')
- Parameters:
files – the list of file names need to be copied, need suffix
src_dir – source directory path
dst_dir – destination directory path
- Returns: