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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:37:42+00:00 2026-06-07T05:37:42+00:00

Alright so using Python with windows I am trying to run a batch command

  • 0

Alright so using Python with windows I am trying to run a batch command which is the “move” command to move files. I am aware it can be done using the shutil in python but it gave me trouble.

move /-y "%~dp0itself.py" "C:\folder\folder2\"

That works perfectly when run alone as a batch file.

import subprocess
    process = subprocess.Popen(move /-y "%~dp0sarpedon.py" "C:\Utility\Config\", shell=True, stdout=subprocess.PIPE)
process.wait()
print process.returncode

I tried adding that to the end of some other code in python but I keep getting errors it says I have invalid syntax because of the at the end of

"%~dp0sarpedon.py   (")

A lot of the attempts I use to fix it end with the error:

EOL while scanning string literal.

Because the closing parentheses

(move /-y "%~dp0sarpedon.py" "C:\Utility\Config\", shell=True, stdout=subprocess.PIPE   ")"

How can I fix this?

  • 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-07T05:37:43+00:00Added an answer on June 7, 2026 at 5:37 am

    Can you specify what trouble shutil gave? Did you forget the double backslash? Or does either the file or the directory require admin privileges?

    Did the following cause an error?

    import shutil
    shutil.move("%~dp0itself.py", "C:\\folder\\folder2")
    

    Running on my 64-bit Windows machine moved the file with this line.

    As to why your code isn’t working — I think its because of the \”, try using double backslashes \, or the string interpreter won’t end the string. Or it will create some weird character in place of all of your separators.

    Try the following with a combined string for the move and destination commands if you’re devoted to using subprocess:

    import subprocess
    process = subprocess.Popen("move /-y %~dp0sarpedon.py C:\\Utility\\Config\\",
                               shell=True, stdout=subprocess.PIPE)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, I'm trying to recreate the old classic, Missile Command, using OpenGL in C++.
Alright, I'm just trying to learn about using Contact information, but I'm a bit
I'm trying to create an environment using virtualenv. virtualenv test New python executable in
I am installing a package using intent. I can install it alright, but this
Alright now i am trying to make a cool looking table with using CSS
Alright, so I downloaded the SpiderMonkey source code using the command wget http://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz and
Alright. I am using a Modal box pop up window to display business details
Alright, so recently I was using Notepad++ for all of my programming needs, but
Alright...I am here looking for some bread crumbs. This is my code: using System;
Alright, i had this homework recently (don't worry, i've already done it, but in

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.