48 lines
2.0 KiB
Plaintext
48 lines
2.0 KiB
Plaintext
# mvparent.sh #
|
|
|
|
mvparent.sh was originally written to be integrated in the ROX-Filer
|
|
directory "Send to" menu (and was named mv_here.sh). It moves the
|
|
contents of a directory into its parent directory, then deletes the
|
|
empty directory.
|
|
|
|
To install this script, just copy it in a directory which is in the
|
|
PATH, e.g. /usr/local/bin:
|
|
cp mvparent.sh /usr/local/bin
|
|
|
|
If you want to integrate it in ROX-Filer:
|
|
mkdir -p ~/.config/rox.sourceforge.net/SendTo/.inode_directory
|
|
cd ~/.config/rox.sourceforge.net/SendTo/.inode_directory
|
|
ln -s `which mvparent.sh` "Move here"
|
|
|
|
|
|
# unln.py #
|
|
|
|
I wrote this script after accidentally merging all my "duplicate" files
|
|
with the cleaning tool fslint (thanks guys for a totally confusing clear
|
|
UI!). It does the opposite than the ln command, that is separate file
|
|
names given as arguments from their respective inodes by doing the
|
|
equivalent of (cp -p file tmp && mv tmp file). Checks are done in order
|
|
to work only on regular files which have more than one hard link, so the
|
|
minimal amount of copies are done.
|
|
|
|
A summary of the file names on which error were raised is displayed at
|
|
the end of the execution. Note that if a file is under a directory which
|
|
is not executable (i.e. the program can't cd in), it will be considered
|
|
as inexistant and ignored, and its name won't be displayed.
|
|
|
|
/!\ Warning: the copy function used is shutil.copy2(), which tries to
|
|
preserve all the metadata it can, but as of Python 3.3 it is not
|
|
guaranteed that extended attributes will be preserved. See the
|
|
documentation for details:
|
|
http://docs.python.org/3/library/shutil.html
|
|
|
|
/!\ FILE OWNER AND GROUP CANNOT BE PRESERVED, as a file is always
|
|
created with the current user's UID and GID.
|
|
|
|
Tip: if you have a file listing all the file names you want to work on,
|
|
with one name per line, you can use xargs with the --delimiter='\n'
|
|
option:
|
|
xargs --delimiter='\n' <list.txt unln.py
|
|
Without this option, you would have troubles with file names containing
|
|
spaces.
|