Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find files with next weeks timestamp 1

Status
Not open for further replies.

bigbalbossa

Programmer
Mar 21, 2002
87
0
0
US
All,

I have a script scheduled to run once every Friday night. Origionally, it was to find files matching the current date in MMDDYY format. Now it needs to match the following Fridays date.

This friday will be 040607...when the script runs on this date, it needs to find files with 041307 in the filename. I've been looking into Date::Calc, but wanted to get this posted...I'm sure KevinADC will beat me to a solution :)

Thanks
 
Code:
[url=http://perldoc.perl.org/functions/use.html][black][b]use[/b][/black][/url] [green]strict[/green][red];[/red]

[black][b]use[/b][/black] [green]Date::Calc[/green] [red]qw([/red][purple]Add_Delta_Days[/purple][red])[/red][red];[/red]
[black][b]use[/b][/black] [green]POSIX[/green] [red]qw([/red][purple]strftime[/purple][red])[/red][red];[/red]

[url=http://perldoc.perl.org/functions/my.html][black][b]my[/b][/black][/url] [blue]@date[/blue] = [url=http://perldoc.perl.org/functions/localtime.html][black][b]localtime[/b][/black][/url][red];[/red]
[blue]@date[/blue][red][[/red][fuchsia]5[/fuchsia],[fuchsia]4[/fuchsia],[fuchsia]3[/fuchsia][red]][/red] = [maroon]Add_Delta_Days[/maroon][red]([/red][blue]@date[/blue][red][[/red][fuchsia]5[/fuchsia],[fuchsia]4[/fuchsia],[fuchsia]3[/fuchsia][red]][/red], [fuchsia]7[/fuchsia][red])[/red][red];[/red] [gray][i]# Add a week[/i][/gray]
[black][b]my[/b][/black] [blue]$date[/blue] = strftime [red]"[/red][purple]%m%d%y[/purple][red]"[/red], [blue]@date[/blue][red];[/red]

[url=http://perldoc.perl.org/functions/print.html][black][b]print[/b][/black][/url] [blue]$date[/blue][red];[/red]

[gray][i]# Output: 041207[/i][/gray]
[tt]------------------------------------------------------------
Pragmas (perl 5.8.8) used :
[ul]
[li]strict - Perl pragma to restrict unsafe constructs[/li]
[/ul]
Core (perl 5.8.8) Modules used :
[ul]
[li]POSIX - Perl interface to IEEE Std 1003.1[/li]
[/ul]
Other Modules used :
[ul]
[li]Date::Calc[/li]
[/ul]
[/tt]

- Miller
 
Thanks Miller. I had a solution, but it was too ugly to post :) Yours is short and to the point.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top