Introduction
cpShuffleSature randomly copies files from one directory to
another. It is designed for copying music, pictures, or films onto
any hardware device (player) which serves as a filesystem (such as
I-Bead, iPod, Archos...).
It will not delete nor modify existing files and is developed
with portability in mind.
It runs on every system where a recent (5.8 is OK) version of Perl is
installed. To use it with MS-Windows you need Perl (explore ActiveState).
cpShuffleSature can:
- select really randomly but not let any file be copied more often than
the others
- select files accross subdirectories and upon a regular expression
applied to the filename (w/o path)
- replicate under the target directory along with the directory
tree
- filter out parts of the original directory names
- leave a given amount of available space on the target
filesystem
- copy entire directory contents or sparse files
- limit the total size of files copied, and/or copied into the same
target directory. and/or enforce a limit expressed as freespace on the
target
- (under Unix) mount the player before copying then unmount it
- understand and print numeric data (file sizes...) expressed with units
("20.5M 1K")
- run in 'verbose' or 'dummy' mode to let you know what it will
do or does
Licence: public domain
Author: Nat Makarevitch
Tested under Linux, please send
your requests, bug reports or patches.
Examples and cookbook
Please read this to obtain a better grasp of the function and usage of this
software: cpShuffleSature_demo.txt
Download
cpShuffleSature (the script), last stable
version (PGP-GPG signature)
cpShuffleSature (the script), last
unstable version (PGP-GPG
signature)
freshmeat, useful for subscribing to new releases
Todo
--destroy option, which deletes target files existing in the source dir
(same size + compares the first, midd and last clusters contents (test
adequation against std multimedia files?))
use it as a player, à la randomplay
with a memory of songs played preserved across sessions, so you don't "lose
your place" if you have to shut down.
"mp3"s to "mpg123"
"ogg"s to "ogg123"
"mid"s to "timidity"
"wav"s to "play"
idea: test program existence
re-encode on the fly, while copying. for example OGG to MP3 or lower
sampling speed
-vv must produce various stats
afin de ne copier que/pas les fichiers arborant un commentaire
donné utiliser (sans qu'ils soient nécessaires) :
MP3::Info libimage-info-perl libvorbis-perl ajouter option regexps
pondérées des filenames et/ou tags (MP3 ...)
augmentant ou diminuant la proba de sélection
multilingue (Locale::gettext), mais sans dépendre de ce
module my $module_B_is_available; essayer avec libmodule-info-perl
BEGIN { $module_B_is_available = eval { require B; B->import; 1
} or do_fixup_code_if_B_not_available(); };
GUI 'Perl Tk' (?) projette la sélection, offre moyen de
sélectionner/déselect, enrichir les regexp de
filtrage ...
Changelog
- 20040704
- various minor enhancements, new stable version
- 20040609
- new scoring scheme, test and let me know
- 20040608
- contribution by Jim Crumley (csbsju.edu): opt_nosubdir support
- last unstable version published
- 20040229 (this is an unstable version, only avail thru CVS (v1.17))
- Work in progress (scoring ...)
- 20040101 (this is a beta version, only avail thru CVS (v1.16))
- More adequate scoring: any new or changed file is now inserted in
history as if we already copied it numerous (90% of the average)
times. memoization (faster).
- The '--prefername a_regexp' option overscores files which names are
selected by the regexp
- 20031206
- The '-n' option now works
- The history file is updated even in case of break (control-C ...)
- 20031203
- The '-w' option now works and sorts (alpha) the directory contents
- One may choose the min age of any processed file (expressed with
human units: week, day ...)
- The history-file content is protected in case of serialization failure
- Numerous enhancements of arguments processing and documentation.
- 20031127
- unit converter for time units
- better unit converter (less risk for ambiguity)
- lockindicator (target) debugged
- better help
- 20031124
- better scoring
- bug related to the infamous 'magic number' fixed
- 20031123
- BEWARE: --ignorehistory suboptions (=1: use and write, =2: use but
don't write, ignore)
- --names modifies history (or use --ignorehistory)
- 20031121
- 20031114
- stores informations about copied files accross runs
- honours locking of directories (.cpsslock)
- 20031103
- enhanced verbose mode
- fastest process
- pathnames normalization (implementation: code borrowed from Joey Hess)
- debug
- 20031031
- all numeric parameters are fetched and printed in human readable
format (approach: Emmanuel Manganneau)
- better messages
- better dummy mode
- selection is now done with a list of directories names (-s) and a
filtering regexp (-f) applied to the filename (without the path)
- 20031029
- all numeric parameters can use units
- ad hoc memoization of the function establishing the avail space
on target
Similar codes
Installation
Linux
You need Perl 5.8, Carp::Assert and Filesys::DiskFree
Debian
invoke 'apt-get install libcarp-assert-perl libfilesys-diskfree-perl'
Other distributions
Please let me know!
FAQ
Name
Stupid name choosen because it is somewhat clear for French and
English speakers.
Arguments under Unix shells
Under Unix do NOT forget to quote the arguments otherwise
interpreted by the shell.
Mounting
Unix users: mount the filesystem exported by your USB device in 'sync' mode
to somewhat reduce the probability of loss after any plug-out done before
umounting. Under Linux the corresponding /etc/fstab entry may be:
/dev/sda1 /mnt/usb vfat defaults,user,noatime,noauto,sync 0 0