You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Being a beginner Being a beginner, I try to find a solution for application needs I create a daily symbolic link with the same naming convention.
Deletion of the last symbolic link type file at the destination
Creation of a symbolic type file at the destination by referring to the file that was created the same day at the source.
In this example the source file starts with the date and time followed by the file name "yyyy_MM_dd_HH_mm_ss_filereport.xls (2021_02_16_10_10_10_filereport.xls).
When the symbolic link is created, it is created without the start date (filereport.xls ".Symlink")
The script below works correctly.
However, I can't do the same thing, when I have several daily files with different names but always starting with the date and time. Anyone have an idea how I can do the same on all the differently named log files?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello
Being a beginner Being a beginner, I try to find a solution for application needs I create a daily symbolic link with the same naming convention.
Creation of a symbolic type file at the destination by referring to the file that was created the same day at the source.
In this example the source file starts with the date and time followed by the file name "yyyy_MM_dd_HH_mm_ss_filereport.xls (2021_02_16_10_10_10_filereport.xls).
When the symbolic link is created, it is created without the start date (filereport.xls ".Symlink")
The script below works correctly.
However, I can't do the same thing, when I have several daily files with different names but always starting with the date and time. Anyone have an idea how I can do the same on all the differently named log files?
$File = Get-Childitem "$Source*.xls" -Recurse | where { $_.CreationTime -gt (Get-Date).AddHours(-2.5)}
$Source = "\share\report"
$Destination = "\Share\Report\Dayly"
$DailyLog = $Files
$Localhost = $Destination + "filereport.xls"
write-host $Source
write-host $DailyLog
pushd $Destination
if (Test-Path $DailyLog -ErrorAction SilentlyContinue) {
if (Test-Path $Localhost -ErrorAction SilentlyContinue) {
remove-item $Localhost -Confirm:$false -Force
Start-Sleep -Seconds 3
}
New-item -ItemType SymbolicLink -Path $Destination -Name ".\filereport.xls" -Value $DailyLog
}
gci | ? { $_.LinkType } | Select FullName, LinkType, Target
popd
Beta Was this translation helpful? Give feedback.
All reactions