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 8181269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:27:52+00:00 2026-06-07T00:27:52+00:00

I am trying to move some files in python, but they have spaces in

  • 0

I am trying to move some files in python, but they have spaces in the name. Is there any way to specifically tell python to treat a string as a file name?

listing = os.listdir(self.Parent.userTempFolderPath)
for infile in listing:
    if infile.find("Thumbs.db") == -1 and infile.find("DS") == -1:

        fileMover.moveFile(infile, self.Parent.userTempFolderPath, self.Parent.currentProjectObject.Watchfolder, True)

After I get the file from the listing, I run os.path.exists on it to see if it exists, and it never exists! Can somebody give me a hint here?

  • 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-07T00:27:54+00:00Added an answer on June 7, 2026 at 12:27 am

    The spaces in the filenames are not the problem; os.listdir returns filenames, not full paths.

    You’ll need to add them to your filenames to test them; os.path.join will do this for you with the correct directory separator for your platform:

    listing = os.listdir(self.Parent.userTempFolderPath)
    for infile in listing:
        if 'Thumbs.db' not in infile and 'DS' not in infile:
            path = os.path.join(self.Parent.userTempFolderPath, infile)
    
            fileMover.moveFile(path, self.Parent.userTempFolderPath, self.Parent.currentProjectObject.Watchfolder, True)
    

    Note that I also simplified your filename tests; instead of using .find(..) == -1 I use the not in operator.

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

Sidebar

Related Questions

I have to move some hard-coded strings to external resources files, and I'm trying
I'm trying to move some Excel-Data to MySQL, but having troubles with encoding. What
I'm trying to use the command prompt to move some files, I am used
A program we have erred when trying to move files from one directory to
We are trying to move some of our media files from our application to
Im trying to use some T-SQL to move some files from one directory to
I'm trying to move some code into some class files to clean up my
I am trying to save a few files that all have the same name.
Trying to move some divs using hover, this is my markup: <div class=item dark-grey>
I am trying to move some model code to a module. The original model

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.