Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #62741 > unrolled thread

Recovering deleted files

Started byGeorge Tang <geosxbox@gmail.com>
First post2013-12-25 20:44 -0800
Last post2013-12-26 16:10 -0800
Articles 5 — 5 participants

Back to article view | Back to comp.lang.python


Contents

  Recovering deleted files George Tang <geosxbox@gmail.com> - 2013-12-25 20:44 -0800
    Re: Recovering deleted files Chris Angelico <rosuav@gmail.com> - 2013-12-27 02:45 +1100
    Re: Recovering deleted files Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-12-26 12:19 -0500
      Re: Recovering deleted files Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-27 09:37 +1100
    Re: Recovering deleted files Rick Johnson <rantingrickjohnson@gmail.com> - 2013-12-26 16:10 -0800

#62741 — Recovering deleted files

FromGeorge Tang <geosxbox@gmail.com>
Date2013-12-25 20:44 -0800
SubjectRecovering deleted files
Message-ID<85df4275-b5a8-41e3-a7aa-80b640790c68@googlegroups.com>
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!

[toc] | [next] | [standalone]


#62742

FromChris Angelico <rosuav@gmail.com>
Date2013-12-27 02:45 +1100
Message-ID<mailman.4634.1388072741.18130.python-list@python.org>
In reply to#62741
On Thu, Dec 26, 2013 at 3:44 PM, George Tang <geosxbox@gmail.com> wrote:
> 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

[toc] | [prev] | [next] | [standalone]


#62746

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2013-12-26 12:19 -0500
Message-ID<mailman.4637.1388078349.18130.python-list@python.org>
In reply to#62741
On Wed, 25 Dec 2013 20:44:39 -0800 (PST), George Tang <geosxbox@gmail.com>
declaimed the following:

>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...
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#62752

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2013-12-27 09:37 +1100
Message-ID<52bcafbd$0$29995$c3e8da3$5496439d@news.astraweb.com>
In reply to#62746
Dennis Lee Bieber wrote:

> 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.


-- 
Steven

[toc] | [prev] | [next] | [standalone]


#62757

FromRick Johnson <rantingrickjohnson@gmail.com>
Date2013-12-26 16:10 -0800
Message-ID<2b93fc03-f017-4450-bd93-05fa39b4f6d4@googlegroups.com>
In reply to#62741
On Wednesday, December 25, 2013 10:44:39 PM UTC-6, George Tang wrote:
> 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???

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web