Skip to content

PorthoGamesBR/AutomatePythonProjectPage240

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automate the Boring Stuff with Python by Al Sweigart

Project Page 240: Renaming Files with Dates

  • Generate a large number of files with american style dates as their names (mm-dd-yyyy).
  • All files have the original date saved in them so you can check if you code worked well after.
  • Simple implementation of the date style conversor presented in the book (american to european).

How to use:

Valid American Style Date Generation:
  • gendates.py -> Prints the help text

  • gendates.py path=Path to save files name=Name of files num=Num of files -> Creates all files

  • gendates.py defalut -> Creates files in default mode DEFAULT: gendates (save in current work directory) "us_date_" 100

  • gendates.py compress path=Path to save files name=Name of Files num=Num of files -> Creates files and compress

  • gendates.py compress default -> Creates files in default mode and compress

Converting to European Date Style:
  • dateconversor.py (Path to files) -> Converts every file inside the path that has american style dates

Functions

gendates.py

  • check_leap(year) - Accepts an integer. Checks whenever that number will be a leap year or not, and returns True if yes and False if not.
  • date_generator(n) - Accepts an integer and returns a list of strings. Generates a list of n size with valid non repeating american style dates.
  • compress_dates(path, name, dates) - path is a pathlib.Path object, name is a string and dates is a list of strings. In the path, for each date in the list, gets the file with name + date and sends it into a .zip file in the same path.

Todo's

gendates.py

  • Getting user command line arguments separated by name
  • Generating valid american dates with a function
  • Compressing all date files in the path to a .zip archive
  • Deleting the original files so we dont get duplicates
  • Organizing main() in different functions

dateconversor.py

  • Regex to indentify american style dates
  • Getting all file names inside the path
  • Indentify the files with valid american style dates
  • Converting the dates in the filenames to european style
  • try/except in re.sub() and .group()
  • Use shutil.move() to change the name of the files
  • Organize code in functions
  • Get user inputed path
  • Check if path is valid

Support

Made based on the book 'Automate the Boring Stuff with Python' by Al Sweigart.

Consider donating to the writer of the book.

And consider following me in my youtube channel about programming

About

Repo of the codes i used to finish the project in the page 240 of Automate The Boring Stuff with Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages