scripts/file_utils/README

66 lines
2.7 KiB
Plaintext

# dirpacker.py #
This scripts allows to group (pack) a bunch of files or directories into
fixed-size volumes, optimizing the occupied size of the volumes. The
original use case was to burn MP3 albums to CD-ROMs to play them in the
car, but minimize the wasted space of each disc. Of course, it can be
used to backup any kind of files to any kind of medium.
The particularity of this program, compared for example to datapacker
(from which it is loosely inspired) is that it works with directories
instead of regular files only. The files inside a directory won't be
separated on several archives, they will be on the same volume.
Note: I kept the datapacker's terminology, a volume is also called a
bin.
To see the usage, call the program with -h.
# 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 errors 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 --delimiter='\n':
xargs --delimiter='\n' <list.txt unln.py
Without this option, you would have troubles with file names containing
spaces.