Python file-finishing tool __python

Source: Internet
Author: User

When doing the project, for convenience, always directly put the file on the desktop. For a long time, the files on the desktop are piling up. When it's time to clean up, sorting is time-consuming. Direct deletion is not reassuring, because some files may still be used.

Usually my approach is to create a new folder, move the file all the way inside, make room for the desktop, and then come back to tidy it up when it's free.

Because I often do this, repeat work. Repeat work should be done by the program. So I wrote a script with Python to achieve this simple function. The following is the source code:

#This Python file uses the following Encoding:utf-8
import OS
import shutil from
datetime import datetime
  
   curdir = Os.curdir

# Create the folder to store the files into current directory
Dstfolder  = Os.path.join (Curdi R, DateTime.Now (). Strftime ('%m-%d%h-%m '))
if not os.path.exists (dstfolder):
    os.makedirs (Dstfolder)

# List and move the "file in current directory" to "folder just created
files = Os.listdir (CurDir) for
F in Files :
    if Os.path.isfile (f) and F!= ' CleanDirectory.exe ':
        srcpath = Os.path.join (CurDir, f)
        Dstpath = Os.path . Join (Dstfolder, F)
        Shutil.move (Srcpath, Dstpath)
  

I've made it into an EXE and can download it here.

Instructions for use:

Put the exe in a directory, double-click to run. Files in the current directory (excluding folders) are moved to a folder (the new folder is named after the current time).

I write it the main purpose is to clean the desktop, put on the desktop, run, the desktop on the removal of the files, saying refreshing.

Attention.

Do not modify the name of the EXE, can be modified to use, but the EXE will also be moved to the new folder.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.