0

In GIT, we have a file called .gitignore, what is the technical term to call them, (are files like these valid to be called as "filename"), What are they supposed to be called?

I have written a simple script in python to change the name of files, however, Python doesn't seem to recognize folders and files that starts with a dot (.) such as .git, .gitignore etc

import os
import glob
rootdir = 'C:\\INBOX\\POLINATE\\JUNKS\\**'

# #work on files
for filename in glob.iglob(rootdir, recursive=True):
    
    if os.path.isfile(filename): # filter dirs        
        print(filename)

        try:                
            ##rename
            new_filename = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(14)).lower()
            new_extension = new_filename[0:3]
            final_name = os.path.dirname(filename) + os.sep + new_filename+'.'+new_extension
            os.rename(filename,final_name)
            print(final_name)

        except Exception as e:
            #raise e            
            print(e)

Script above works for files with Xn.3 format (Xn filenames within allowable range including spaces).(Three (3) letter extension) but it leaves files starting with a dot (.)

enter image description here

mirageservo
  • 2,387
  • 4
  • 22
  • 31

1 Answers1

0

Files starting with . are mainly hidden files that you don't need in many cases.

In your case .git and .gitignore are the supporting files for git operations. Actually your program dont need these files to run. .gitattributes files contains your git informations and .gitignore file tells git to ignore the git supporting files.

You can see a .vs file in the same folder. I assume you are using vscode and it might be the information files of vscode.

shamnad sherief
  • 552
  • 5
  • 17