Posted On March 28, 2019

Batch File to Copy Files Containing Agents’ Names

kimconnect 0 comments
blog.KimConnect.com >> Codes >> Batch File to Copy Files Containing Agents’ Names
:: Set variables using system time and date
popd
Set today=%Date:~4,2%_%Date:~7,2%_%Date:~10,4%
IF “%today:~0,1%”==”0” ( SET today=%Date:~5,1%_%Date:~7,2%_%Date:~10,4%
IF “%today:~3,1%”==”0” ( SET today=%Date:~5,1%_%Date:~8,1%_%Date:~10,4%
)
)
echo %today%
pause
IF “%today:~2,1%”==”0” ( SET today=%Date:~4,2%_%Date:~8,1%_%Date:~10,4%
IF “%today:~0,1%”==”0” ( SET today=%Date:~5,1%_%Date:~8,1%_%Date:~10,4%
)
)
echo %today%
pause
:: Set P: to direct to the directory with the Agent files
net use P: \\FILESERVER01\Users\Recordings /persistent:yes /user:FILESERVER01\sysadmin {PASSWORD}
IF NOT EXIST P:\ THEN GOTO END
md “P:\person1\%today%”
md “P:\person2\%today%”
md “P:\person3\%today%”
pause
popd
:: Set directory to the folder where all the recordings are
pushd C:\Inetpub\ftproot\recordings\New Leads Campaign\%today%
:: Loop through each folder and it’s subfolders and do…
For /r %%G in (.) do (
pushd %%G
:: If there’s a file containing the word “Agent”, copy it to the folder “Trainee”
copy /y “*Agent*” “P:\Trainee\%today%”
:: If there’s a file containing the Agent’s name (fname letter + full lname), copy it to their folder
copy /y “*person1*” “P:\acyr\%today%”
copy /y “*person2*” “P:\gladalardo\%today%”
copy /y “*person3*” “P:\jcullen\%today%” )
popd
pushd C:\Inetpub\ftproot\recordings\Campaign1\%today%
For /r %%G in (.) do (
copy /y “*person4*” “P:\person4\%today%”
)
popd
pushd C:\Inetpub\ftproot\recordings\campaign2\%today%
For /r %%G in (.) do (
copy /y “*person5*” “P:\person5\%today%”
)
popd
:: Set directory to the folder where all the recordings are
pushd C:\Inetpub\ftproot\recordings\Recapture Campaign\%today%
:: Loop through each folder and it’s subfolders and do…
For /r %%G in (.) do (
pushd %%G
:: If there’s a file containing the word “Agent”, copy it to the folder “Trainee”
copy /y “*Agent*” “P:\Trainee\%date”
:: If there’s a file containing the Agent’s name (fname letter + full lname), copy it to their folder
copy /y “*person1*” “P:\person1\%today%”
copy /y “*person2*” “P:\person2\%today%”
copy /y “*person3*” “P:\person3\%today%”
)
net use P: /delete
:END

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: 1-Liner to Change Computer Name and Join Active Directory

# The 1-liner Add-Computer -DomainName 'somedomain.com' -credential kimconnect.com\domainadmin1 -ComputerName $env:computernname -newname 'NewName' -restart # Quick…

VSS Error: Snapshots were found, but they were outside of your allowed context

Error: PS C:\Windows\system32> vssadmin delete shadows /for=c: /allvssadmin 1.1 - Volume Shadow Copy Service administrative…

PowerShell: Invoke Backup SQL Database

Function to invoke SQL Backups on a Remote SQL Server: # invokeSqlBackup.ps1 # Version 0.0.1…
Other project: DragonCoin.com