Home IT Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Python Dir find a folder several files     - MySQL High Availability plan several options (Database)

- Java development specifications summary (Programming)

- Linux disk partition batch format mount script (Linux)

- Udev: Device Manager for Linux Fundamentals (Linux)

- CentOS terminal display Chinese (Linux)

- Grub2: Save Your bootloader (Linux)

- Making Linux root file system problems on-link library (Programming)

- Android Activity launchMode (Programming)

- Django Web dynamic three linkage (Programming)

- Linux command Detailed chpasswd bulk edit user password (Linux)

- An example of troubleshooting of embedded Linux OpenWRT (Linux)

- Install Java 8 on Ubuntu using PPA (Linux)

- Asynchronous communication mechanism between the Android source code analysis thread (Programming)

- Linux Firewall Builder shorewall (Linux)

- Git version rollback (Linux)

- Android imitation UC browser scroll up and down functions (Programming)

- DELL D630 Wireless LAN Driver Installation CentOS6 (Linux)

- Ambari and Hadoop configuration, management and monitoring of the project Getting (Server)

- How to download GOG games in Linux command line (Linux)

- Java multi-threaded communications pipeline flow (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.
- Python console achieve progress bar (Programming)
- Ubuntu 15.04 installation Powercommands 2.0 (Linux)
- To install the Oracle process notes on Oracle Linux 4u4 (Database)
- Oracle GoldenGate tutorial Second, configure and use (Database)
- Linux Getting Started Tutorial: How to set up a static MAC address on VMware ESXi virtual machine (Mobile)
- Linux non-graphical interface to install Oracle Database (Database)
- Spring3 + SpringMVC + Hibernate4 full annotation environment configuration (Server)
- Use eCryptFS encrypt files and directories on Linux (Linux)
- To achieve Linux Security (Linux)
- Use GLOBK batch command network adjustment (Linux)
- Source code to compile and install MySQL 5.7.9 (Database)
- Linux md5sum verify file integrity (Linux)
- Ubuntu manually set the DSL broadband connection (Linux)
- Nginx + uWSGI + Django + Python Application Architecture Deployment (Server)
- SSH port forwarding application (Server)
- Compile and install GCC 4.8.1 + GDB 7.6.1 + Eclipse in CentOS 6.4 in (Linux)
- Java Set and List in the relationship and difference (Programming)
- Linux Network Statistics Tools / Command (Linux)
- Installation Flow N Play- interface stylized video player on Ubuntu (Linux)
- grub boot error resolution examples (Linux)
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.