Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Quick Question about batching files

by Boxerman (Initiate)
on Feb 07, 2013 at 11:31 UTC ( [id://1017619]=perlquestion: print w/replies, xml ) Need Help??

Boxerman has asked for the wisdom of the Perl Monks concerning the following question:

Morning all, I've got a quick question about batching files,
I'm pretty new to Perl so need a pointing in the right way with some explaining.

I would like to make a perl script which search a sub folders of the folder its been told to search and goes through and batches the files in a increaing order, for example:

It creates a folder called Batch1 which has 250 files in there, then Batch2 which has 251, Batch 3 - 252, Batch4 - 253 etc...

How can i do this? Is it possible?

Many thanks!
B-man

Replies are listed 'Best First'.
Re: Quick Question about batching files
by choroba (Cardinal) on Feb 07, 2013 at 11:39 UTC
    Yes, this is possible. To do that, you should read and understand opendir, glob, rename and File::Copy, maybe even File::Find...
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Hey, thanks for the rapid response! +1

      However is there any sites i can use as examples to play with there code? and learn that way (its how i learnt php)

      Thanks again,
      B-man
        Also don't get put off by this
Re: Quick Question about batching files
by tmharish (Friar) on Feb 07, 2013 at 11:49 UTC
    perl script which search a sub folders

    And then you say...

    creates a folder called Batch1 which ...

    Do you want to read files or write them?

    Or do you want to do both? If so, the folders you are reading from - what do they look like? Also which OS ( just in case find . works for you )?

    Batch1 which has 250 files in there, then Batch2 which has 251 ...

    Batch1 contains 250 files and Batch2 has 251 files or do you want to store files 251 to 500 in it?

    Also see How do I post a question effectively?
      All thanks for your responses and help.

      In regards to reading the file, i dont want that, i just want a count of files and sort them in to the folders until there are no more files left.

      Thanks
      B-man
        ...sort them in to the folders...

        Sort by which criteria? Name? Contents?

        This is probably the main point that makes the question difficult to answer ... and maybe why some answers may seem rude or vague.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1017619]
Approved by vinoth.ree
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-24 07:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found