0

I want to extract the date of an empty file , example :

Orders_05012015.txt

This, to occupy it as a variable to query the database.

select * from orders Where date = $$Date_order (05012015)

I try to do this task by command , but I only get it via examples of AWK and I'm in windows

Example via awk:

SET CompletePath=\\192.168.20.175\infa_shared\SrcFiles\CRED20102009.csv
SET JustFileName=`basename $CompletePath`
echo $JustFileName|awk -F"." '{print $1}'|awk '{print substr($1,length($1)-7, length($1))}'

2 Answers2

1

You can use PowerShell in Windows

$a=[io.path]::GetFileNameWithoutExtension("\\192.168.20.175\infa_shared\SrcFiles\CRED20102009.csv")
$a.substring($a.length-8,8)
Samik
  • 3,437
  • 2
  • 20
  • 27
1

There are awk implementations for Windows:

Gawk for Windows
Microsoft's answer
From StackOverflow

Community
  • 1
  • 1
Michael Back
  • 1,821
  • 1
  • 14
  • 17