레이블이 script인 게시물을 표시합니다. 모든 게시물 표시
레이블이 script인 게시물을 표시합니다. 모든 게시물 표시

6/24/2010

olym opt

-start=s,mMets

8/06/2009

nautilus script : copy selected path to clipboard



#!/usr/bin/python
# -*- coding: UTF-8 -*-
# file copy_sel_path_to_clipboard.py

import os, gtk #, glob

def showme(s):
os.system('gmessage -center -title "Path" "' + str(s) + '"')

tmp = os.environ['NAUTILUS_SCRIPT_SELECTED_FILE_PATHS']
fns = tmp.strip().split('\n') #filenames
if len(fns) == 1 :
cb = gtk.clipboard_get()
cb.set_text(fns[0])
cb.store()
else :
showme('Only 1 file must be selected')

7/30/2009

nautilus script : backup script

This script copy the selected files in the folder named 'old'.
If the folder is not exist, the script create 'old' folder.
Time stamp strings, e.g. "_Thu_Jul_30_11.05.39_2009", are automatically attached at the end of the file name.


#!/usr/bin/python
# -*- coding: UTF-8 -*-

import os, glob, time

old = 'old' # backup folder name

def showme(s):
os.system('gmessage -center ' + str(s))

def make_time_str():
tmp = time.ctime()
tmp = tmp.replace(' ', '_')
tmp = tmp.replace(':', '.')
return tmp

def make_old_folder():
if len(glob.glob(old)) == 1 and os.path.isdir(old) :
pass #
else :
os.system('mkdir old')

return

make_old_folder()

# get selected file paths
tmp = os.environ['NAUTILUS_SCRIPT_SELECTED_FILE_PATHS']
fns = tmp.strip().split('\n') #filenames

for fn in fns : # for filename in filenames
if os.path.isdir(fn) :
#showme('pass')
pass
fn_nameonly = os.path.basename(fn) # extract file name from file path
#showme(os.path.splitext(fn)[1])
cmd = 'cp ' + '"' + fn_nameonly + '" old/"' + fn_nameonly + '_' + make_time_str() + os.path.splitext(fn)[1] + '"'
os.system(cmd)

The script file must be in ~/.gnome2/nautilus-scripts/