方法一:
在系統可以上網的條件下:
1、安裝工具:tree;
2、在終端輸入
tree -f -i > file_list_path
file_list_path 文件內容即為當前目錄下所有文件的相對路徑
方法二:
在系統無法上網的情況下:
1、編寫python腳本
import os root = os.getcwd() def file_name(file_dir): with open(root+'_pwd', 'w', encoding='utf-8') as f: # 使用with open()新建對象f for root_dir, dirs, files in os.walk(file_dir): for file_names in files: print('.' + root_dir[len(root):] + '/' + file_names) file_path = '.' + root_dir[len(root):] + '/' + file_names f.write(file_path + '\n') # 寫入數據,文件保存在上面指定的目錄,加\n為了換行更方便閱讀 f.close() # 關閉文件 file_name(root)
2、在需要查看的目錄下運行python 腳本即可