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 from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Script: Rename files based on date

  • 11-04-2006 9:37am
    #1
    Registered Users, Registered Users 2 Posts: 11,987 ✭✭✭✭


    Ok, Here's what I'm tyring todo.

    I have a reporting tool which dumps pdf reports into a folder each night/weekend/month end

    These file names are constant, what I want todo is to move the files into a folder based on the the Week.

    eg.

    Create a weekly folder - Week 15 ( date +%V ) and move the relevant files into that folder with the date prefix - "Sales-11-04-06"

    Each nightly report would go into the weekly folder along with the relevant weekend reports.

    So the Weekly folder will contain each nightly report along with its weekly report.

    Same goes for the Monthly reports, a folder created like - "April" and the reports moved into that folder and renamed.

    Any helpers


Comments

  • Registered Users, Registered Users 2 Posts: 2,747 ✭✭✭niallb


    A couple of quick suggestions:
    Call the folders Sales-06-04-11 rather than Sales-11-04-06.
    That way they will list in calendar order.

    For the monthly folders use 04 rather than april for the same reason.

    Can you edit the reporting tool, or do you want to rename afterwards?

    NiallB


  • Closed Accounts Posts: 96 ✭✭krinDar


    zabbo wrote:
    I have a reporting tool which dumps pdf reports into a folder each night/weekend/month end

    These file names are constant, what I want todo is to move the files into a folder based on the the Week.

    Help us help you - provide us with more information.

    What is the current directory layout and file names. I don't mean examples
    that you have made up, I was the actual layout as on the system.

    We have _no_ idea what the directory structure and filename format
    consists of so trying to give you an answer with this is like trying to
    piss into an unsighted jam jar on a dark windy night.


  • Registered Users, Registered Users 2 Posts: 11,987 ✭✭✭✭zAbbo


    Its a samba folder called 'Reports'

    A windows based reporting app dumps pdf's into this folder. I want to file them accordingly. There are 7 reports run from Mon-Fri, and week reports run on Sat, and Month reports run on the 1st of the month(reporting on the previous month). Filenames will be in the format 'reportname.pdf' e.g sales.pdf etc. These daily reports will be overwritten with the weekly report at the weekend, so the sales.pdf will refer to the weekly one. So a seperate script can be crontab'd to do that at the weekend.

    So far i've got
    #!/bin/bash
    
    WEEK=Week-`date +%V`
    TODAY=`date +%y-%m-%d`
    
    if [ -d $WEEK ] ; then
    cp sales.pdf $WEEK/sales-$TODAY.pdf ; else
    mkdir $WEEK
    cp sales.pdf $WEEK/sales-$TODAY.pdf
    fi;
    


Advertisement