Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
FTPlib - moving a file
#1
Hi,

I'm trying to move a file called: "Rec1_20180122.avi" into a folder named '20180122' with no success.

I've googled a bit, and I came to the conclusion that I should do it with ftp.rename(src, dst).

Could you please help me out with this issue? It just doesn't work. I tried this as well:

f = 'Rec1_20180122.avi'
d = '20180122'

ftp.rename(f, ftp.cwd(d))
Reply
#2
Did you try:
ftp.rename('Rec1_20180122.avi', '20180122/Rec1_20180122.avi')
"just doesn't work" isn't a thing.
If something other than what was expected happens, tell us what. If you get an error, post it. Some code reproducing it would also be nice.
Reply
#3
Thanks, it doesnt work yet:

ftp.rename(f, '/' + str(day))
ftp.rename(str(f), '/' + str(day) + '/')
These are the error messages:

ftp.rename(f, '/' + str(day))
  File "C:\Python\lib\ftplib.py", line 608, in rename
    return self.voidcmd('RNTO ' + toname)
  File "C:\Python\lib\ftplib.py", line 276, in voidcmd
    return self.voidresp()
  File "C:\Python\lib\ftplib.py", line 249, in voidresp
    resp = self.getresp()
  File "C:\Python\lib\ftplib.py", line 242, in getresp
    raise error_temp(resp)
ftplib.error_temp: 451 Rename/move failure: Invalid cross-device link

Success!

It needed full path:

ftp.rename('/{}/{}'.format(storage, f),'/{}/{}/{}'.format(storage, day, f))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Functions to consider for file renaming and moving around directories cubangt 2 1,746 Jan-07-2022, 02:16 PM
Last Post: cubangt
  how can we record a video file from our program output (moving object) Zhaleh 0 1,806 Aug-03-2020, 02:47 PM
Last Post: Zhaleh
  Python 3.7.4 (FTPLib Deprecated). Now What? bmccollum 1 2,596 May-16-2020, 03:17 PM
Last Post: Larz60+
  transfering files between server locations using ftplib katesfb 1 1,995 Nov-11-2019, 12:24 AM
Last Post: katesfb

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020