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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:51:14+00:00 2026-05-29T09:51:14+00:00

I am trying to do $ mv <file> .. in a python script using

  • 0

I am trying to do $ mv <file> .. in a python script using subprocess.call(). I am able to do this on ‘normal’ filenames, but on certain filenames it does not work. I do not have control of the filenames that are given to the script. Here is an example:

M filename is "ITunes ES Film Metadata_10_LaunchTitles(4th Batch)_08_20_2010.XLS"

When I try and do the command directly into the python prompt and drag the file into it, this is what I get:

>>> /Users/David/Desktop/itunes_finalize/TheInventionOfLying_CSP/
    ITunes\ ES\ Film\ Metadata_10_LaunchTitles\(4th\ Batch\)_08_20_2010.XLS

No such file or directory

How would I go about moving this file in a python script?

Update:

Thanks for the answers, this is how I ended up doing it:

for file in glob.glob(os.path.join(dir, '*.[xX][lL][sS]')):
    shutil.move(file, os.path.join(os.path.dirname(file), os.path.pardir))
  • 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-05-29T09:51:14+00:00Added an answer on May 29, 2026 at 9:51 am

    subprocess is not the best way to go here. For example, what if you’re on an operating system that isn’t POSIX compliant?

    Check out the shutil module.

    >>> import shutil
    >>> shutil.move(src, dest)
    

    If finding the actual string for the filename is hard you can use glob.glob to pattern match what you want. For example, if you’re running the script/prompt from the directory with the .XLS file in question you could do the following.

    >>> import glob
    >>> glob.glob('*ITunes*.XLS')
    

    You’ll get a list back with all the file strings that fit that pattern.

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

Sidebar

Related Questions

Im trying to call an external python script, and so far i was able
I'm trying to host a python script using an apache web server, but the
I am trying to plot two columns from a text file using python matplotlib
I'm trying to insert some import lines into a python source file, but i
I'm trying to copy files inside a Python script using the following code: inf,outf
I'm trying to write parsing script using python/scrapy. How can I remove [] and
I'm trying to write a Python script for searching out duplicate mp3/4 files using
I'm trying to run a python file using Notepad++'s NppExec plugin. My file attempts
I'm trying to create a python script that logs into JIRA using their REST
I am trying to compile a python script using pyinstaller with modules like scientific,MMTK.

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.