ammartahir1978
asked on
how to pick only current date files from a ftp
Hi All,
I have a folder on ftp where all the files sit i just want to pick all the today's dated files.
Currently i am using this
now you can see i have to change mget A20161031*.* to todays date which is A20161103*.*, i have to do this everytime how can i change it so that system automatically pick current dates files?
(edit: replaced userid and passwrod with generics)
I have a folder on ftp where all the files sit i just want to pick all the today's dated files.
Currently i am using this
open 10.10.34.5
userid
password
lcd D:\LABELS\ChessODBCFiles\BedfordSO
cd chess_new/bedford
binary
mget "A20161031*.*"
disconnect
quit
now you can see i have to change mget A20161031*.* to todays date which is A20161103*.*, i have to do this everytime how can i change it so that system automatically pick current dates files?
(edit: replaced userid and passwrod with generics)
ASKER
Hi oBda,
I have this simple txt file which i run via schedule job.
so how do i run your script?
I have this simple txt file which i run via schedule job.
so how do i run your script?
A text file doesn't execute itself. Are you using the Windows default ftp.exe, or which application (with which arguments) are you currently using to run the ftp script you posted?
ASKER
this is how i run it
ftp -i -s:"D:\LABELS\ChessODBCFil es\FtpPick SO.txt"
ftp -i -s:"D:\LABELS\ChessODBCFil
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks odBa where does it save the log file and whats the name?
ASKER
Excellent thank you so much
As defined in line 3.
ASKER
hi oBda,
the script is not working i just changed the location to put files in.
can you check please.
Am
the script is not working i just changed the location to put files in.
can you check please.
$TimeStamp = Get-Date -Format 'yyyyMMdd'
$mgetPattern = "A$($TimeStamp)*.*"
$LogFile = 'C:\Users\atahir\Documents\FtpPickSO.log'
$FtpFile = Join-Path -Path $ENV:Temp -ChildPath 'ChessODBCFiles.ftp'
@"
open 10.10.34.5
ediftp
shelbyv1lle
lcd C:\Users\atahir\Documents\SALES_FILES
cd chess_new/bedford
binary
mget "$($mgetPattern)"
disconnect
quit
"@ | Set-Content -Path $FtpFile
& ftp.exe -i -s:$FtpFile 2>&1 | Set-Content -Path $LogFile
Regards,Am
What is not working? The scheduled instance or the script in general?
What does the log file say?
What happens if you open a PS console, "cd" into the folder where the .ps1 file is stored, and run it manually from there?
What does the log file say?
What happens if you open a PS console, "cd" into the folder where the .ps1 file is stored, and run it manually from there?
ASKER
this is what i get when i run it manually
error-powershell.PNG
error-powershell.PNG
Well, then the path to the ps1 file is obviously incorrect.
You need to fix the path inside the single quotes.
You need to fix the path inside the single quotes.
ASKER
got it thank you stupid of me :) sorry to bother you
No problem. Sometimes things are just too obvious.
Open in new window