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: Add Quorum to Clusters

# SetClusterQuorum.ps1$clustersAndQuorums=@();$clustersAndQuorums+=[PSCustomObject]@{ClusterName='CLUSTER1';Quorum='\\FILESHERVER007\CLUSTER1$'};$clustersAndQuorums+=[PSCustomObject]@{ClusterName='CLUSTER2';Quorum='\\FILESHERVER007\CLUSTER2$'};function getViableNode{ param($nodes) foreach ($node in $nodes){ $bingo=Test-NetConnection $node -InformationLevel Quiet; if($bingo){return $node} }}…

Microsoft SQL Cloning Database to a Different DB Name

# User defined variables $sourceSqlServer='DEV-SQL01' $sourceDatabaseName='TEST_MSCRM' $sourceSaCredential=$(get-credential) $destinationSqlServer='DEV-SQL01' $destinationDatabaseName='Test_MSCRM' $destinationSaCredential=$(get-credential) function copyDatabase{ param( $sourceSqlServer, $sourceDatabaseName,…

PowerShell: Change Windows Autolock

# Disable_AutoLock.ps1function changeAutoLock{ param ( [Switch]$disable, [Switch]$enable ) $registryHive = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization" $registryKey="NoLockScreen" $keyItem = Get-ItemProperty…