0

I want to move and replace a file example cat.txt with another file example dog.png in such a way that in the folder now only dog.png only exists.

I don't want to remove cat.txt and add dog.png which is a 2-step process. I want to replace.

These are 2 files with different names.

I am planning to rename dog.png to cat.txt and then after moving and replacing the original cat.txt with new cat.txt, I will rename back the new cat.txt as dog.png

Naif
  • 41
  • 1
  • 6
  • can you explain more ? – Ankush Rathi Aug 22 '17 at 07:25
  • Possible duplicate of [Move and replace if same file name already existed in python](https://stackoverflow.com/questions/31813504/move-and-replace-if-same-file-name-already-existed-in-python) – Thyrst' Aug 22 '17 at 07:28
  • 1
    This doesn't make any sense to me. You can't replace file with different name... You could rename `cat.txt` and than replace it or replace it and than rename it but you can't do what you want in just one step. – Thyrst' Aug 22 '17 at 07:32
  • Yes Looks like i cannot do this in 1 step – Naif Aug 22 '17 at 08:42

0 Answers0