ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233
Rep:
mass renaming script
can anyone help me with either a simple shell script, c, or c++ program to take files from a digital camera labeled (IMGXXXX.JPG) and reverse the order of how they are numbered?
Well, one way is to create a list of your files in order eg
ls -1 |sort >sort.dat
then a list in reverse
ls -1|sort -r>rsort.dat
then a script eg in shell to open each file and read through both files, renaming fileN in sort.dat to fileN in rsort.dat.
#!/usr/perl -ns
BEGIN {
warn "-chomp to ignore new line characters\n" unless $chomp;
warn "-neat for nice easier spacing\
(hint: finish off with 'fmt' command)\n" unless $neat;
warn "\n";
}
chomp if $chomp;
@L = unpack("H2" x length($_), $_) ;
print $neat? "@L\n":@L;
binary_read.pl
Code:
#!/bin/perl -n
tr/01//cd;
print pack "B*" , $_;
binary_write.pl
Code:
#!/usr/bin/perl -ns
BEGIN {
warn "-chomp to ignore new line characters\n" unless $chomp;
warn "-neat for nice easier spacing\
(hint: finish off with 'fmt' command)\n" unless $neat;
}
chomp if $chomp;
@L = unpack "B8" x length($_), $_ ;
print $neat? "@L\n":@L;
Hey BB, I'm not sure
@ARGV = <IMG*>;
guarantees the list will be in order... Also, you need a separate output dir, otherwise when file eg A1 moves to eg A4, you've lost A4 before you can move it to A1 (assume basic list is A1, A2, A3, A4 etc)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.