Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8445203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:36:07+00:00 2026-06-10T09:36:07+00:00

So, I’m trying to make myself a Python script which goes through the selected

  • 0

So, I’m trying to make myself a Python script which goes through the selected Music folder and tells the user if specific album doesn’t have an album cover. It basically goes through all the files and checks if file[-4:] in (".jpg",".bmp",".png"), if true, it found a picture file. Just to make it clear, the structure of my folders is:

  • Music folder
    • Arctic Monkeys
      • Humbug (2009)
      • Suck it and see (2011)
    • Morphine
      • Cure For Pain (1993)

.. and so on. I’m testing the script to find if there’s a missing cover in my Arctic Monkeys directory, and my script goes through the “Humbug (2009)” folder and finds AlbumArtSmall.jpg which doesn’t show up in the command prompt so I tried “Show hidden files/folders” and still nothing. However, the files show up once I uncheck “Hide protected operating system files”, so that’s kinda weird.

My question is – how do I tell Python to skip searching the hidden/protected files?
I checked out the How to ignore hidden files using os.listdir()? but the solution I found there only works for files starting with “.”, and that’s not what I need.

Cheers!


Edit – so here’s the code:

import os

def findCover(path, band, album):
    print os.path.join(path, band, album)
    coverFound = False

    for mFile in os.listdir(os.path.join(path, band, album)):
        if mFile[-4:] in (".jpg",".bmp",".png"):
            print "Cover file found - %s." % mFile
            coverFound = True
            return coverFound

musicFolder = "E:\Music"   #for example
noCovers = []

for band in os.listdir(musicFolder):    #iterate over bands inside the music folder
    if band[0:] == "Arctic Monkeys":    #only Arctic Monkeys
        print band
        bandFolder = os.path.join(musicFolder, band)
        for album in os.listdir(bandFolder):
            if os.path.isdir(os.path.join(bandFolder,album)):
                if findCover(musicFolder, band, album): #if cover found
                    pass                                #do nothing
                else:
                    print "Cover not found"
                    noCovers.append(band+" - "+album)   #append to list
            else:                       #if bandFolder is not actually a folder
                pass
        print ""
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:36:08+00:00Added an answer on June 10, 2026 at 9:36 am

    You can use with the pywin32 module, and manually test for FILE_ATTRIBUTE_HIDDEN or any number of attributes

    FILE_ATTRIBUTE_ARCHIVE              = 32
    FILE_ATTRIBUTE_ATOMIC_WRITE         = 512
    FILE_ATTRIBUTE_COMPRESSED           = 2048
    FILE_ATTRIBUTE_DEVICE               = 64
    FILE_ATTRIBUTE_DIRECTORY            = 16
    FILE_ATTRIBUTE_ENCRYPTED            = 16384
    FILE_ATTRIBUTE_HIDDEN               = 2
    FILE_ATTRIBUTE_NORMAL               = 128
    FILE_ATTRIBUTE_NOT_CONTENT_INDEXED  = 8192
    FILE_ATTRIBUTE_OFFLINE              = 4096
    FILE_ATTRIBUTE_READONLY             = 1
    FILE_ATTRIBUTE_REPARSE_POINT        = 1024
    FILE_ATTRIBUTE_SPARSE_FILE          = 512
    FILE_ATTRIBUTE_SYSTEM               = 4
    FILE_ATTRIBUTE_TEMPORARY            = 256
    FILE_ATTRIBUTE_VIRTUAL              = 65536
    FILE_ATTRIBUTE_XACTION_WRITE        = 1024
    

    like so:

    import win32api, win32con
    
    #test for a certain type of attribute
    attribute = win32api.GetFileAttributes(filepath)
    #The file attributes are bitflags, so you want to see if a given flag is 1.
    # (AKA if it can fit inside the binary number or not) 
    # 38 in binary is  100110 which means that 2, 4 and 32 are 'enabled', so we're checking for that
    ## Thanks to Nneoneo
    if attribute & (win32con.FILE_ATTRIBUTE_HIDDEN | win32con.FILE_ATTRIBUTE_SYSTEM):
      raise Exception("hidden file") #or whatever
    
    #or alter them
    win32api.SetFileAttributes(filepath, win32con.FILE_ATTRIBUTE_NORMAL) #or FILE_ATTRIBUTE_HIDDEN
    

    After you alter a file, take a look in the folder, it won’t be hidden anymore.

    Found this information here and here: Checking file attributes in python


    Alternatively, you can try to use the os.stat function, whose docs here and then use the stat module to further understand what you’re looking at.

    Found these relevant questions. (python) meaning of st_mode and How can I get a file's permission mask?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to select an H1 element which is the second-child in its group
I am trying to loop through a bunch of documents I have to put
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.