GithubHelp home page GithubHelp logo

dove6 / clean-files Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 881 KB

Perl exercise - script for cleaning up user directories

License: MIT License

Rich Text Format 94.98% Python 0.01% Perl 5.01%
perl5 warsaw-university-of-technology

clean-files's Introduction

Clean files

A simple, interactive Perl script for tidying up your documents, photos, music... by detecting duplicates, temporary and empty files.

An assignment for the "Unix System and TCP/IP Network Administration" course.

Task

Let's assume we have a multitude of documents, video records, movies and photos in directory X and its subdirectories. We also store one or more copies of those files in directories Y1, Y2, ..., but the copies can be named differently and be located at a different point of the directory tree. There may even appear some files that are present in Y1, Y2, ... dirs, but not in X.

Clean up the file structure so that:

  • directory X stores all the files,
  • exact duplicates are removed: only the oldest one of files sharing the same content is left as the others are probably backups,
  • empty and temporary files are removed,
  • from among files sharing the same name, only the newest one remains,
  • file attributes are unified (eg. rw-r--r--),
  • troublesome characters in filenames (eg. :, ", ., ;, *, ?, $, #, `, |, \, ...) are substituted with a safe one (eg. _).

Users should be prompted to confirm any permanent modification (eg. removing, renaming or moving a file).

The script should be able to search for:

  • files sharing the same content (but not necessarily the same name or relative location),
  • empty files,
  • files sharing the same name (but not necessarily the same relative location),
  • temporary files (with names ending with ~, .tmp or other, user-defined extensions),
  • files with atypical attributes (eg. rwxrwxrwx),
  • files with names containing troublesome characters.

The script should suggest a proper action for each found file:

  • moving or copying the file to directory X,
  • removing the duplicate, empty or temporary file,
  • replacing the older version with the newer version,
  • replacing the newer version with the older version (for files with identical content),
  • changing file attributes,
  • changing file name,
  • no action.

Performing all the actions may require the script to be run several times (for example in the first run the script deals with all empty files, in the second run it removes duplicates, etc.).

Configuration including:

  • file attributes after unification, eg. rw-r--r--,
  • list of troublesome characters,
  • a substitute for troublesome character,
  • extensions of temporary files

should be read from a file, eg. $HOME/.clean_files.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.