Recovering deleted files

G

George Tang

I am new to python and was trying to program with txt files, and tried to move the txt file to a new directory. i did not read very carefully about what shutil.move(src, dst) does and it deleted some of my files. How do i recover my lost files. plz help!
 
C

Chris Angelico

I am new to python and was trying to program with txt files, and tried to move the txt file to a new directory. i did not read very carefully about what shutil.move(src, dst) does and it deleted some of my files. How do i recover my lost files. plz help!

Ouch. I'm afraid Python can't really help you there; you have to go to
your OS and file system now. Do as little as you possibly can on that
disk and you might be able to recover the contents. If you're lucky,
your file system won't have reused those parts of the disk, so
everything'll be intact... if you're REALLY lucky, you might even be
able to find the bits you want without searching the whole disk. But
it depends now on your OS and FS, not on Python.

This is why we make backups of all important files. I like to use
source control (git for me, or you could use Mercurial or another one
with the same result), which makes backing up an inherent part of all
work. But everyone has those critical files that they didn't know
weren't backed up... :(

ChrisA
 
D

Dennis Lee Bieber

I am new to python and was trying to program with txt files, and tried to move the txt file to a new directory. i did not read very carefully about what shutil.move(src, dst) does and it deleted some of my files. How do i recover my lost files. plz help!

If I read the documents properly, shutil.move() does not just blindly
delete files (it does a copy/delete if crossing file systems, otherwise it
just does a rename).

So where did to instruct it to put what had been the source
file/directory? Look in that destination location...
 
S

Steven D'Aprano

Dennis said:
If I read the documents properly, shutil.move() does not just blindly
delete files (it does a copy/delete if crossing file systems, otherwise it
just does a rename).

What difference does that make? Regardless of whether you do a copy/delete
or rename, whatever file was overridden by the move is still overridden.
 
R

Rick Johnson

I am new to python and was trying to program with txt
files, and tried to move the txt file to a new directory.
i did not read very carefully about what shutil.move(src,
dst) does and it deleted some of my files. How do i
recover my lost files. plz help!

Well George that's unfortunate.

I hate to say "i told you so", but i've been preaching the
importance of testing code that manipulates files for many
years. If only you had run the code a few times and MERELY
printed the src and dst paths to stdout you MIGHT could have
saved yourself a tough lesson.

But all may not be lost.

If you want to post the relevant bits of the source code we
may find a solution for you. Maybe your path munging was
clumsy and you moved them somewhere unexpected... who
knows???
 
Joined
Sep 21, 2024
Messages
18
Reaction score
1
I am new to python and was trying to program with txt files, and tried to move the txt file to a new directory. i did not read very carefully about what shutil.move(src, dst) does and it deleted some of my files. How do i recover my lost files. plz help!

If your files were deleted during the move process, you can try a few manual methods to recover them. First, check your Recycle Bin as moved files might have been sent there. If they are not in the Recycle Bin, you can try restoring from a backup if you have one. You can also use Windows' "Previous Versions" feature by right-clicking the folder where the files were located.
For a more efficient solution, you can use BLR Data Recovery Tool. This software is designed to recover lost, deleted, or even formatted files from your system. It offers an easy-to-use interface and advanced scanning to recover your lost files quickly and effectively.

Hope this will help you :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,056
Messages
2,570,446
Members
47,097
Latest member
MarionMajo

Latest Threads

Top