Code Monkey home page Code Monkey logo

batch-renamer's People

Contributors

5kyc0d3r avatar darko3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

yjfintalkdev

batch-renamer's Issues

Comments

A few comments from glancing over your source:

  • #!/usr/bin/python: You need to specify a python version. This won't point to Python 2 on all linux distros.

  • --help\t\t\t\tprint: Tab escape keys make your docstring harder to read. Just insert actual tabs or spaces instead.

  • self.license_agree != "yes" or "y" or "n" or "no": This will always return True because False or "y" == True. The proper solution for is:

    any(self.license_agree in ('yes', 'y', 'no', 'n'))
    
  • os.mkdir("%s/.batch-renamer-cli" % home): It's poor form to dump your configuration/temp files in the current directory. (At least for linux) see:

    from gi.repository import GLib
    GLib.get_user_data_dir()
    GLib.get_user_cache_dir()
    GLib.get_user_config_dir()
    
  • Enclosing your print statements in parenthesis will go a long way towards working with both python 2 and 3.

  • print "Finished renaming %s files with a total time of %s seconds." % (self.file_counter, total_time): Neither of these variables are strings, you should use the appropriate formatting flags %d and %f.

  • end = time.time(): On windows, time.clock() is much more accurate. (On linux time.clock() is straight up wrong though).

  • enter_to_continue = raw_input(...: this should be split into lines at each \n for readability.

  • sys.exit(0): An exit status of 0 means success. You should be exiting with a non-zero status for errors.

  • The MIT license doesn't permit the notice to be removed but you've made it an integral active part of the program. It should be reproduced in a comment at the top of the file. This will make it easier for others to modify your code without violating your license.

  • class Main():: you aren't using this as a class, so it doesn't need to be a class. This would suffice:

    def main():
            myName = 'hello world'
        def rename():
            RENAME_FUNCTION(myName)
    

Or even better, get rid of the global variables:

def rename(old_name, new_name):
    # ...
def main():
    myName = 'hello wrold'
    rename(myName, 'hello world')

In general, passing values as function arguments is better than relying on a single variable to hold all your parameters.

  • elif self.license_agree == "yes": replace that elif with a simple if and you no longer need to duplicate code in the preceding if statement.
  • for file in files: in python 2, file is a preexisting type variable.
  • A try block should encompass as little code as possible. Reduce your try: ... except OSError to only the lines that can produce that error. Also, this can be an important error when renaming files, make it known to the user when this error is raised unless you specifically expect it in a particular place.

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.