Avatar of bergquistcompany
bergquistcompany
 asked on

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

Avatar of undefined
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*")
      {

$fullpath = $FileObj.FullName
$sourcefolder = "\\server1\GVP96\Downloads\"
$destFolder = "path you want to copy files to"
$copypath = ($fullpath -replace [regex]::Escape($SourceFolder), '')
$destpath = $DestFolder + $copypath

write-host "processing $fullpath" -fore green
Copy-Item $fullpath $destpath

}
Brian

Just schedule a simple one line batch file.

xcopy \\server1\GVP96\Downloads\BER1004_86204_EESETUP_SCHED_*.txt \\server1\destination

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?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
becraig

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?
ASKER CERTIFIED SOLUTION
becraig

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
bergquistcompany

ASKER
awesome
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.