Jump to content
Usr6

Python - file random jumping script

Recommended Posts

Posted (edited)

Scriptul de mai jos "sare" in alt director -ales aleator- de fiecare data cand este executat


Am fost in: C:\BugsBunny.py
Acum sunt in: C:\WINDOWS

Am fost in: C:\WINDOWS\BugsBunny.py
Acum sunt in: C:\Documents and Settings\LocalService\Local Settings\Temp
..


#Python 2.7
import random
import sys
import os
import shutil

file_name = sys.argv[0]
print "Am fost in:", file_name
random_dir = random.randint(1, 10000)

i = 0
for root, subfolders, files in os.walk("C:\\"):
for folder in subfolders:
i += 1
if i == random_dir:
dir_path = os.path.join(root, folder)
shutil.move(file_name, dir_path)
print "Acum sunt in:", dir_path
raw_input()
sys.exit()

Edited by Usr6

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...