1

After I recovered my files with PhotoRec, I ran fdupes $ fdupes -rdNI --sameline /home/user > fdupes.txt. I couldn't use the option -d because round about 1.6 million files in my system have been recovered. I also ran fdupes several times until it found no more duplicates.

The thing is that I got lots of entries in fdupes.txt (> 50 MB) being in the structure of

   [+] /home/user/recup/jar/f105168728.jar
   [-] /home/user/a/path/to/dir/and/file/myfile_1.ending
   [-] /home/user/another/path/to/dir/and/file/myfile_2.ending

Is there a script or already written program which moves the 'recup' files to the path where I arranged them in order in my directories?

Many of the directories won't be there because I also did $ find /home/user/ -depth -type d -empty -exec rmdir {} \; afterwards.

Can I create folders with subfolders in them in one single step in python (script) or another language?

1 Answer 1

0

Here's a script in python3 I wrote:

import os
import sys
import ast
import time
import signal

n = 1
from = 'asdf'
into = 'asdf'
d = '/home/user/fdupes.txt'
f = open ( d, "r" )

from = f.readline ()
into = f.readline ()

while '/' in from or '/' in into :
 if ( '[+] /home/user/recup/' in from ) and not ( 'recup' in into ) and ( '[-] /home/user/' in into ) :
  from = from.split ( '[+] ' ) [1]
  from = from.split ( '\n' ) [0]
  into = into.split ( '[-] ' ) [1]
  end = into
  ( into, name ) = os.path.split (into)
  end = end.split ( '\n' ) [0]
  if os.path.isfile (from) :
   if not os.path.isfile (end) :
    if not os.path.isdir (into) :
     os.makedirs (into)
    os.rename (from, end)
 else :
  from = into
  into = f.readline ()
 n += 1
f.close ()
print ("Ready!")

But I think it cannot create sth like home/user/sub/dir/of/a/file/ when there's an empty home/user/sub/dir/, can it? Do I have to run it several times for that?

I don't think so, but I'm also not sure...

If it can, I got a solution :-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .