LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-23-2007, 06:26 PM   #1
Blyiss
LQ Newbie
 
Registered: Feb 2007
Distribution: Linux debian 2.6.18-3-486 #1 Mon Dec 4 15:59:52 UTC 2006 i686 GNU/Linux
Posts: 24

Rep: Reputation: 15
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.

Last edited by Blyiss; 02-23-2007 at 06:28 PM.
 
Old 02-23-2007, 08:42 PM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
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.
 
Old 02-23-2007, 11:43 PM   #3
Blyiss
LQ Newbie
 
Registered: Feb 2007
Distribution: Linux debian 2.6.18-3-486 #1 Mon Dec 4 15:59:52 UTC 2006 i686 GNU/Linux
Posts: 24

Original Poster
Rep: Reputation: 15
Thank you for the valuable advice. Perl sounds great!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
A puzzle Gins Linux - General 10 02-24-2007 07:23 AM
copying/moving stalls when moving a lot of data to a usb stick =X¥®µ§= Linux - Hardware 10 07-30-2004 05:29 AM
Simple C Puzzle sansk Programming 20 05-22-2004 04:09 PM
Printer Puzzle seanmaggs LinuxQuestions.org Member Success Stories 0 03-30-2004 05:04 PM
A puzzle for you to figure out, I can't cpeppler Linux - Software 12 10-06-2003 12:37 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration