Moving several directories with relative paths did not work because the script was not going back to its original working directory.
|11 months ago|
|README.md||4 years ago|
|dirpacker.py||4 years ago|
|mvparent.sh||11 months ago|
|prefixsubdirs.sh||4 years ago|
|unln.py||4 years ago|
This scripts allows you 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, while minimizing the amount of wasted space on 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
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
mvparent.sh was originally written to be integrated in the ROX-Filer
directory “Send to” menu. 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 your
bin directory provided with the repository, as explained in the main
If you want to integrate it in ROX-Filer:
mkdir -p ~/.config/rox.sourceforge.net/SendTo/.inode_directory cp mvparent.sh ~/.config/rox.sourceforge.net/SendTo/.inode_directory/"Move here"
The use case for this script is to flatten a file hierarchy, for instance switching from:
dir1 |-- dirA |-- dirB `-- dirC
dir1 ; dirA dir1 ; dirB dir1 ; dirC
prefixsubdirs.sh will only rename the subdirectories (not the
regular files) within the given directories, it will not actually flatten the
hierarchy. You can use
mvparent.sh for this purpose (see above).
I wrote this script after accidentally merging all my “duplicate” files with
the cleaning tool
fslint (thanks guys for a totally confusing UI!). It does
the opposite of the
ln command, that is it separates 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
that 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
non-existent and ignored, and its name won't be displayed.
/!\ Warning #1: the Python copy function used is
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.
/!\ Warning #2: file owner and group cannot be preserved, as a file is always created (upon copy, in our case) 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 --delimiter='\n' <list.txt unln.py
(Without this option, you would have troubles with file names containing spaces.)