Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

File Creation

Options
  • 03-09-2009 10:22am
    #1
    Registered Users Posts: 757 ✭✭✭


    Hi all,
    Does anyone know of a way I could make a structure something like:

    Folder 1
    -100 Files
    Folder 2
    - 100 Files
    *5 Folders.

    The content of the files is irrelevant but I really don't want to manually create these files manually. Is there any kind of automation for example which would record you making one and let you pass in 'n' variable and all filename'n'.doc as the name or something?

    Thanks


Comments

  • Closed Accounts Posts: 95 ✭✭jingx3


    If you're using anything but M$ Windoze, open a terminal and try something like:
    for i in `seq -w 100`
    do
      touch file-$i.doc
    done
    

    This will create empty files named file-001.doc, file-002.doc, etc. If you have a file you want to copy 100 times, change the 'touch' line to:
    cp template-file.doc file-$i.doc
    


  • Registered Users Posts: 2,781 ✭✭✭amen


    you can do this in windows as well
    open a command prompt
    for /L %i IN (1,1,5) DO md myDirectory%i

    this will loop starting at 1 in steps creating a directory called myDirectory1, myDirectory2 etc until it gets to 5

    to create the files
    create some a blank file template and use
    for /L % IN (1,1,5) DO copy myFile.txt c:\myDirectory1\myfile%1.txt
    this will take myFile create create copies numbered 1 to 5 in myDirectory1

    I'm curious why you need this though?


  • Closed Accounts Posts: 2,696 ✭✭✭mark renton


    amen wrote: »
    you can do this in windows as well
    open a command prompt
    for /L %i IN (1,1,5) DO md myDirectory%i

    this will loop starting at 1 in steps creating a directory called myDirectory1, myDirectory2 etc until it gets to 5

    to create the files
    create some a blank file template and use
    for /L % IN (1,1,5) DO copy myFile.txt c:\myDirectory1\myfile%1.txt
    this will take myFile create create copies numbered 1 to 5 in myDirectory1

    I'm curious why you need this though?

    brilliant - isnt it great when a little code does a lot


  • Registered Users Posts: 2,781 ✭✭✭amen


    it is
    I'm a lazy programmer the less lines of code I have to write the better


  • Closed Accounts Posts: 20 boars.ie


    amen wrote: »
    it is
    I'm a lazy programmer the less lines of code I have to write the better

    A lazy programmer means a good programmer.


  • Advertisement
  • Registered Users Posts: 576 ✭✭✭pts


    boars.ie wrote: »
    A lazy programmer means a good programmer.

    Except if lazy means not commenting and formatting code. :)


  • Registered Users Posts: 2,781 ✭✭✭amen


    A lazy programmer means a good programmer.

    that why I said it although some people just think I mean lazy as it not wanting to work (which would be nice as well)


Advertisement