banner
Previous Page
PCLinuxOS Magazine
PCLinuxOS
Article List
Disclaimer
Next Page

Tip Top Tips: How To Save Media Files To Device In Correct Order


Editor's Note: Tip Top Tips is a monthly column in The PCLinuxOS Magazine. Each month, we will feature -- and possibly even expand upon -- one tip from the PCLinuxOS forum. The magazine will not accept independent tip submissions specifically intended for inclusion in the Tip Top Tips column. Rather, if you have a tip, share it in the PCLinuxOS forum's "Tips & Tricks" section. Your tip just may be selected for publication in The PCLinuxOS Magazine.

This month's tip comes from PCLinuxOS forum member .

It can be really frustrating, when your photo-display device or your personal stereo does not display or play your files in the right order. This is due to some devices just playing the files in the order they are saved, and the ext3/ext4 filesystems' way of storing files (for speedier recovery). So, they are not saved in the order that you would expect, when bulk transferred to a FAT16 or FAT32 device. Now of course, when you use Linux, everything is sorted into the correct order when it's important, but the copy command doesn't do this. Fortunately the rsync command does.



In this instance, you need to change the words in red, to the actual file paths you are using to store the files on your drive, and the words in blue, to the actual path to the medium when mounted.

#!/bin/bash

rm -rf /media/device-name/*

rsync -arvP /home/your-user-name/Pictures/viewer/* /media/device-name

Create a text file as above, give it a suitable name, and in the file manager, use right-click > properties to make it executable.

After rsync, only -ar is strictly necessary, but adding vP might be useful if you run the script in a terminal, so you can see what's happening and get an idea of progress.

Oops! One thing I forgot to mention. Make sure your filenames do not start with a mixture of lower and upper case, unless you want all the uppercase ones to display or play first, and the lowercase ones afterwards.

***

Our dear and recently departed Tara-Rain-9.5B added in a reply to the original Tip & Trick that the following line should be able to perform a case insensitive sort on the file names (enter the command below all on one line):

find /sourcedir -type f -print0 | sort -f | xargs -J % -0 rsync -arvP % /destinationdir

The command above should replace the rsync line in 's script above.



Previous Page              Top              Next Page