On Windows, I'm using this feature (right-hand text) of the excellent cam2pc software to download images&videos from my camera and rename them in the same step. I haven't found any software for Linux that does the same, or does it as good. Suggestions please?
Details and requirements:
- I am using Picasa for everything after the download and I want to keep using it.
- I want a better download functionality than what Picasa offers.
- I know that some tools can do batch renaming after the download, but that's limited to those inside one folder. I want to specify the renaming scheme before the download, in a one-step process.
- Must run on PCLinux 2009.2 (Mandriva variant with KDE).
- Should autodetect that the camera has been plugged into the pc.
- Must download JPG and AVI files.
- Must support a user-customizable pattern for the downloaded files, like
path/year/year-month-day hour-min TOPIC serial#.lowercase-extension
e.g.photos/2009/20091218 1214 Skiing with friends 001.jpg
(In cam2pc, that would look like%Y%m%d %h%u %P %{num:3}.%{ext}
)
By the way, I'm new to Linux and not a programmer, so I am hoping that solutions already exist that aren't too technical, or well documented.
Answer
A custom solution requires a little programming -- I need to write a shell script:
Use the
find
command to see if the newly mounted USB drive contains media files;
if no media files are found, then abort the script.find "/media/disk/dcim" -iname "img*.*" -type f
Use the
read
command to prompt for a topic. (Equals%P
in the question.)Find the timestamp of the oldest media file.
ls -GgtR --full-time --time-style +"%Y%m%d %H%M" *.png | tail -1 | cut -c21-34
- Hints:
-GgtR
= hide group and owner, sort by time, list Recursively.tail
= keep only the last 1 line of the output.cut
= keep only the characters 21-34.
- Hints:
Use
mkdir
to create a new folder based on that date and topic.Use the
find
command with the-execdir
option to find all media files,
then move (mv
) each hit to the new folder,
then usejhead
to rename each hit according to each file's timestamp.Optional: Use the
umount
command to unmount the USB drive.Set up Linux to execute this script when an USB drive is mounted. The detection of the USB drive (or camera) varies depending on the Linux variant; refer to OS-specific documentation. Or just run the script manually...
I'll need to spend invest some hours in learning bash commands, and also in learning how Linux mounts drives.
No comments:
Post a Comment