scripts/file_utils/README

80 lines
3.4 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 in which a volume is also
called a bin.
The default bin size is 703 MiB, i.e. the capacity of a 80-minute
CD-ROM; note that this can lead to slightly exceed the capacity when
actually burning the disc, so if you don't want to overburn a few
hundreds KiB, choose a lower bin size (702 MiB should be fine).
By default, dirpacker displays a list of bins and the files they
would contain, along with the size of each file and some statistics.
With the option --machine-readable, this list will be printed in a
machine-readable format: each line contains a bin's name, then a
tabulation, then a file that belongs to this bin.
With the option --move, a directory will be created for each volume and
the files will be moved to the corresponding volume.
To see the full 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.