Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
rautd
New Member

mssparkutils.fs.mv is giving : java.io.IOException: when trying to move files

Hi All,

 

I am trying to move files from one a workspace in one subscription to another workspace in another subscription using mssparkutils.fs.mv. mssparkutils.fs.cp is working file. I am able to copy files but move is giving error.

 

We have created trusted workspace between the subscription. Also created shortcut for second workspace. Below is the code that I am using - 

import os
for file in mssparkutils.fs.ls(scripdeltapath):  
    updated_path = os.path.join(stagingdeltapath, file.name) 
    print(f"Moving from {file.path} -> {updated_path}")
    try:
        mssparkutils.fs.cp(file.path,updated_path)
    except Exception as e:
           print(str(e))
        mssparkutils.notebook.exit("Error: Something went wrong!", status="error")

 

Let me know if you need more infromation.

 

Thanks,

Deepmala

1 ACCEPTED SOLUTION
AndyDDC
Super User
Super User

Hi @rautd have you tried adding the parameters that create the destinations directory?

 

mssparkutils.fs.mv(file.path,updated_path,True,True)
 
 
mssparkutils.fs.mv('source file or directory', 'destination directory', True) # Set the last parameter as True to firstly create the parent directory if it does not exist

mssparkutils.fs.mv('source file or directory', 'destination directory', True, True) # Set the third parameter to True to firstly create the parent directory if it does not exist. Set the last parameter to True to overwrite the updates.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @rautd 

 

I used your code to move files from one workspace to another workspace without experiencing any error. I tried mssparkutils.fs.mv and mssparkutils.fs.cp, both worked. What error did you get when moving files? Is there any error message?

In addition, if you move files to a workspace which locates in the same Fabric Capacity as the source Workspace does, will it succeed?

 

More information: in my testing, I was using ABFS paths and moving files across workspaces within the same Fabric Trial Capacity. 

 

Best Regards,
Jing

Hi,

 

For me as well, cp worked but mv was giving IOException error as mentioned in my post. Also I have created shortcuts and by using that shortcuts I was trying to move files from workspace to another in two different subcriptions.

AndyDDC
Super User
Super User

Hi @rautd have you tried adding the parameters that create the destinations directory?

 

mssparkutils.fs.mv(file.path,updated_path,True,True)
 
 
mssparkutils.fs.mv('source file or directory', 'destination directory', True) # Set the last parameter as True to firstly create the parent directory if it does not exist

mssparkutils.fs.mv('source file or directory', 'destination directory', True, True) # Set the third parameter to True to firstly create the parent directory if it does not exist. Set the last parameter to True to overwrite the updates.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Fabric Update Carousel

Fabric Monthly Update - September 2025

Check out the September 2025 Fabric update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.