Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Programming \ Python Dir find a folder several files     - Distributed Firewall Design on Linux platform (Linux)

- The security administrator network analysis tools SATAN Introduction under Linux (Linux)

- Installation and Configuration OpenVPN server and client on Ubuntu 15.04 (Server)

- Java loop list to solve the problem of Joseph ring (Programming)

- How Bluetooth turned off by default in Ubuntu 14.04 (Linux)

- MySQL group_con cat_max_Len (Database)

- File easier to compare tools under Linux (Linux)

- How to configure MongoDB replica set (Database)

- Python calls the API interface in several ways (Programming)

- Inherent limitations of Linux systems network security (Linux)

- Linux ban single-user mode to enhance system security (Linux)

- Linux package management operations Basic entry (Linux)

- CentOS 7 hard disk expansion toss record (Linux)

- Oracle Execute to Parse perform analytical Ratio Analysis (Database)

- JDK comes with tools jinfo (Linux)

- CentOS 6 rapid deployment of Java applications (Linux)

- Justniffer installed on Ubuntu 15.04 (Linux)

- Ubuntu 15.10 / 14.04 install subtitling software Aegisub (Linux)

- Browser caching mechanism on the analysis (Linux)

- SQL in the specific internal Oracle process (Database)

  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.
- Linux remote landing system (Linux)
- RHEL 6.5 x86_64 CentOS yum configuration source (Linux)
- Vi / Vim prompt solutions do not have permission to save time (Linux)
- How to clear the DNS query cache under Linux / Unix / Mac (Linux)
- The most common and most effective security settings under linux (Linux)
- Ubuntu 14.04 VirtualBox can not start solution (Linux)
- Linux Security trust with users (Linux)
- Open MySQL slow query log (Database)
- Linux ls command (Linux)
- Oracle 11g dataguard main library backup and recovery to the test environment in one database error (Database)
- Modify grub solve computer startup error: ERROR 17 (Linux)
- How to use systemd timer (Linux)
- Based AutoYaST automated installation of SUSE practice (Linux)
- ORA-12547: TNS: lost contact error Solution (Database)
- Some practical tips Linux (Linux)
- How to update the ISPConfig 3 SSL Certificates (Server)
- LogStash log analysis display system (Linux)
- Linux System Getting Started Tutorial: mounted directly in Linux LVM partition (Linux)
- Java coding conventions (Programming)
- Install NetBeans IDE 8.0 on Ubuntu, Linux Mint, Elementary OS, and Debian (Linux)
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.