- 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).
-
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
dateconversor.py (Path to files)-> Converts every file inside the path that has american style dates
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.
- 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
- 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
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