Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Python Dir find a folder several files     - Git 2.5 increase in the working tree, triangle improved workflow performance (Linux)

- The sublime into IDE (Linux)

- C # Future: Method Contract (Programming)

- Cross server / client backup command: rsync use (Server)

- Understand ASP.NET 5 running the command: DNVM, DNX, and DNU (Server)

- BusyBox build root file system (Linux)

- MongoDB 3.2 Cluster Setup (Database)

- MongoDB upgrade from 2.4.9 to 2.6.0 and PHP record of mongo extension upgrade from 1.4.5 to 1.5.1 (Database)

- Kafka cluster deployment (Server)

- Ubuntu install ruby (Linux)

- Tune in high resolution to 1280x800 in Fedora 14 (Linux)

- Mac OS X command line to submit the local project to Git (Server)

- Docker ecosystem security is gradually maturing (Server)

- Two programs HAProxy + Heartbeat (note, the secondary server vip, normal HAProxy boot method) (Server)

- Installation and configuration of Hadoop under Linux (Server)

- Linux systems for entry-learning - Install Go language in Linux (Linux)

- CentOS minimal network is unavailable resolved (Linux)

- HomeKit User Interface Guidelines (Linux)

- First start with Kali Linux 2.0 (Linux)

- The three-way division of the sorting algorithm Quicksort (Programming)

 
         
  Python Dir find a folder several files
     
  Add Date : 2017-08-31      
         
       
         
  Preface: colleagues encountered a problem and needs to find the file in 7000 tens of thousands of documents, messy. I checked the Python relevant information, although not completely resolved, but there are still things recorded.

First, for a folder through the file, os.walk can be broken. If multiple folders, then, with isdir, isfile and other functions can be broken (parameter optional):

for i in os.walk (os.getcwd (), topdown = True, onerror = None, followlinks = False):
    print i

os.path under judging function:
exists () Specifies the path (file or directory) exists
isabs () Specifies whether the path is an absolute path
isdir () Specifies whether the path exists and is a directory
isfile () Specifies whether a file exists and the path is
islink () Specifies whether the path exists and is a symbolic link
ismount () Specifies whether the path exists and is a mount point
samefile () whether two paths point to the same file name

Such returns i [3] for the list of file names, but I do not know what order, it is necessary to sort based on the file information, and to see how you need, how to sort.
For example, to sort the file has access time:

for i in os.walk (os.getcwd (), topdown = False):
    for j in i [2]:
        print j, os.path.getctime (j)

In os.path, the following functions on the file information:

getatime () Returns the last access time (float Seconds)
getctime () returns the file creation time
getmtime () returns the most recent file modification time
getsize () Returns the file size (in bytes)
abspath () returns the absolute pathname
normpath () path specification string
Obtain specific information, like the rest of the deal. sorted sorting function can be broken, the focus is not here, temporarily introduced.
     
         
       
         
  More:      
 
- Ubuntu FAQ solutions (Linux)
- The Zabbix2.4.5 source compiler installation under Ubuntu 14.04 (Server)
- RAID disk array Description (Linux)
- OpenGL Superb Learning Notes - Vertex Shader example (Programming)
- AngularJS achieve picture upload feature (Programming)
- Ubuntu 12.04 installation DHCP Server (Server)
- Installation Docker FAQ on Ubuntu (Linux)
- iOS persistence of data archiving NSKeyedArchiver (Programming)
- Linux yum command Detailed (Linux)
- CentOS static IP network configuration (Linux)
- Android Studio Getting Started Hello World (Programming)
- The Java way to stop a thread of execution (Programming)
- The bulk batch multiple rows of data collect (Database)
- Windows Server 2012 R2 Datacenter install SQL Server 2016 CTP (Database)
- Import and export myloader accelerate mydumper (Database)
- Linux, grep, sed usage (Linux)
- Linux operating system must know the security command (Linux)
- Ubuntu 12.04 configure NVIDIA CUDA 5.5 Record (Linux)
- libreadline.so.6: can not open shared object file problem solution (Linux)
- MongoDB collection data migration to MySQL database (Database)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.