LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Moving Puzzle (https://www.linuxquestions.org/questions/programming-9/moving-puzzle-531832/)

Blyiss 02-23-2007 06:26 PM

Moving Puzzle
 
Hello, guys. I need a script for moving files.
There are a lot of examples and tutorials but I can't find anything like this:
I have a folder "DIR" that contains subfolders "DIR/a", "DIR/b" and "DIR/c". And each subfolder contains files ",1", ",2" and ",3".
Question: how can I move these files to the subfolder DIR/x in such a manner that files would be renamed and lined up in the following order: "1, 2, 3, 4, 5, 6, 7, 8, 9", if the folder DIR/x is empty. And if it already contains some files, the order would continue starting from the smallest name of the file like : "10, 11, 12 and so on" ?

Will be very grateful for any help.

wjevans_7d1@yahoo.co 02-23-2007 08:42 PM

If you've been looking for a bash script to do stuff like this, you probably have indeed been frustrated. If bash can be used for this, it's only by doing very arcane tricks.

I think it's time you took your relationship with your computer to the next level. Try looking into Perl. Play around with it, and then look at the opendir, readdir, closedir, and rename functions.

You will have a bit of learning to do, but it will stand you in good stead in the long run.

Start here:

http://perldoc.perl.org/

Visit the tutorials, the FAQ, and the reference links (probably in that order) in the upper lefthand corner of that page.

Hope this helps.

Blyiss 02-23-2007 11:43 PM

Thank you for the valuable advice. Perl sounds great!


All times are GMT -5. The time now is 02:15 AM.