RE: [challenge] folder encryption 04-17-2015, 07:37 PM
#7
(04-17-2015, 04:41 PM)Touka Wrote: By automatic, I mean after the file name is inputted, the written program would go through the process of changing the extension without any manual intervention.
(And yeah ik it's not encryption but I couldn't think of a better term)
Well, for that you'd need to have a program that runs in the background constantly and monitors all the filenames that you change. I mean, what would be the use of such a program? It'd be much better to just change the filenames of certain files in a given directory. Like so:
Code:
import os
path = r'/path/to/file'
os.chdir(path)
exts = ['.exe', '.rar', '.zip']
for item in os.listdir('.'):
if os.path.isfile(item):
for ext in exts:
if os.path.splittext(path)[1] == ext:
os.rename(path, os.path.splittext(path)[0] + '.php')I'll add a recursive function later but this'll have to do for now. I'm currently on a phone with shitty signal and it's a bumpy ride. Sorry for any mistakes, it's untested.
















![[+]](https://sinister.li/images/modern/collapse_collapsed.png)