Jun-25-2019, 04:05 PM
Hello experts,
I am facing this issue with os.rename
I have multiple scripts in my Jupyter notebook, and at some point I need to move some files to the "processed" folder.
When I run below code
src - C:\Users\marcin\Desktop\CCC\_External_ New Topic_ _Visio process map for customer account creation_ in Receivables & Collections.msg
dst - C:\Users\marcin\Desktop\CCC\processed\_External_ New Topic_ _Visio process map for customer account creation_ in Receivables & Collections.msg
But when I uncomment last line - os.rename(s, d), I am getting this error with double backslashes in my path:
If so, how to release the the file?
I am facing this issue with os.rename
I have multiple scripts in my Jupyter notebook, and at some point I need to move some files to the "processed" folder.
When I run below code
import os post_id='66ec21db97' for s,n in majle.items(): if n==post_id: d = re.sub(r'CCC\\',r'CCC\\processed\\',s) print('src - {}'.format(s)) print('dst - {}'.format(d)) # os.rename(s, d)I am getting correct output:
src - C:\Users\marcin\Desktop\CCC\_External_ New Topic_ _Visio process map for customer account creation_ in Receivables & Collections.msg
dst - C:\Users\marcin\Desktop\CCC\processed\_External_ New Topic_ _Visio process map for customer account creation_ in Receivables & Collections.msg
But when I uncomment last line - os.rename(s, d), I am getting this error with double backslashes in my path:
Error:PermissionError Traceback (most recent call last)
<ipython-input-11-b0460c8bfdbc> in <module>
6 print('src - {}'.format(s))
7 print('dst - {}'.format(d))
----> 8 os.rename(s, d)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\marcin\\Desktop\\CCC\\_External_ New Topic_ _Visio process map for customer account creation_ in Receivables & Collections.msg' -> 'C:\\Users\\marcin\\Desktop\\CCC\\processed\\_External_ New Topic_ _Visio process map for customer account creation_ in Receivables & Collections.msg'
Is this the issue with backshales or some previous script indeed is blocking the file?If so, how to release the the file?