Nightly process produces file name that needs to be moved and renamed. Is this possible?
I have scheduled an export to run daily. The directory to where the export is scheduled to be run is hard coded and cannot be changed. Is it possible to schedule another process to pick up the export and dump it into another folder where I have another program that needs to call it?
The export is running to: \\server1\GVP96\Downloads with a file name of: BER1004_86204_EESETUP_SCHED_20121227_173754 (where 20121227 is the YYYYMMDD and changes each day and where 173754 is a number assigned by the software and changes each day) and is a text document.
The program that needs to pick it up looks in another directory on another server.
Windows Server 2003Active DirectoryNetworking
Last Comment
bergquistcompany
8/22/2022 - Mon
becraig
you can write a powershell script to do this:
Here is an idea.
$FileList = Get-ChildItem \\server1\GVP96\Downloads -recurse | Where-Object {$_.PSIsContainer -eq $True}
ForEach ($FileObj in $FileList) {
if ($fileobj.Name -like ("*20121227*")
{
This will move all files with that name to the destination folder. Save that one line as a batch file and schedule it to run after the export will finish.
bergquistcompany
ASKER
@washburnma this will be perfect, but one question is can the file BER1004... be renamed to import.txt on the destination side as that is the file name the software looks for to pick up?
My script above would provide that flexibility with one extra line but it seems you don't want to go that route.
bergquistcompany
ASKER
@becraig
I'd love to try it, can you help me with the added line for taking the .txt file and renaming to user.csv? Then can I use schedule task to run this script daily?
Here is an idea.
$FileList = Get-ChildItem \\server1\GVP96\Downloads -recurse | Where-Object {$_.PSIsContainer -eq $True}
ForEach ($FileObj in $FileList) {
if ($fileobj.Name -like ("*20121227*")
{
$fullpath = $FileObj.FullName
$sourcefolder = "\\server1\GVP96\Downloads
$destFolder = "path you want to copy files to"
$copypath = ($fullpath -replace [regex]::Escape($SourceFol
$destpath = $DestFolder + $copypath
write-host "processing $fullpath" -fore green
Copy-Item $fullpath $destpath
}