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
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back a page or two to re-sync the thread and this will then show latest posts. Thanks, Mike.

bat/cmd file help

  • 12-05-2005 12:51pm
    #1
    Registered Users, Registered Users 2 Posts: 902 ✭✭✭


    Howdy, need to write a bat/cmd file and need a little help. It has to do a simple function that after crawling through the web, seems not so simple.

    I have a folder on a server that contains sub-folders. Basically i need to write a script that runs as a scheduled task (every week/month, etc). And the script has to keep the sub-folders less than a month old, and delete everything else.

    In other words the folder on the server fills up on an irregular basis (could be 3 new sub folders a day, could be none) and we need to keep all folders for the past month and delete the rest...

    Messing about with dates through dos is worknig out to be a right b!tch...

    Any help appreciated


Comments

  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 92,385 Mod ✭✭✭✭Capt'n Midnight


    One way is to use the XCOPY /D /D:ddmmyy command - you copy all files less than a month old to a new folder and delete the rest and them copy them back

    pharsing the date to get a month and decrementing it is messy but can be done with FOR loops.


    http://www.robvanderwoude.com/index.html


  • Registered Users, Registered Users 2 Posts: 68,317 ✭✭✭✭seamus


    Would it help any to install Perl or PHP on the server and use a PHP/Perl script to do this?

    Perl is a whizz with this kind of thing.


  • Registered Users, Registered Users 2 Posts: 1,253 ✭✭✭gobby


    Could even try python scripting. I had to use python recently in college for various file operations and I found it quite nice. The website has a great help section too.


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 92,385 Mod ✭✭✭✭Capt'n Midnight


    I'm not sure how consistant syntax has been over time in Python / Perl / PHP

    but the XCOPY command is all over the place with four main flavours :(
    * Dos/Dos Mode in 9x no /D
    * Win 9x command prompt /D
    * NT 3/4
    * 2K/XP (exclude , needing /Y to overwrite etc.)
    there are subtle differences too within the flavours...


  • Registered Users, Registered Users 2 Posts: 902 ✭✭✭thesteve


    Cheers for the replies lads, I'll give the XCOPY a go and let ye know how I get on... Never used perl before although getting training in it in a few weeks...


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 105 ✭✭nutzboutstuff


    why make it so complicated, install cygwin, and bash script it! a couple of greps an xargs and rm -rf and you're sorted, more details and i'll write it for you, and then you can cron it on the server for automatic execution


Advertisement