Luis Diaz
asked on
Powershell & Windows batch: move log files and it equivalent based on contain
Hello experts,
I would like to cover an additional need related to question https://www.experts-exchange.com/questions/29153505/Powershell-Windows-Batch-Vbscript-move-files-based-on-contain.html
Solution proposed move log files from input to output if one file contains at least one line which doesn't start with 0.
Powershell approach:
Batch approach:
Additional need:
In input folder I have .log file and also it .csv file equivalent example : ReqXXXX.log and ReqXXXX.csv,
I would like:
-move log file in output (as is)
-move csv file equivalent into an output2 folder
Assumption:
-Every log file has it csv equivalent.
If you have questions, please contact me.
Thank you for your help.
I would like to cover an additional need related to question https://www.experts-exchange.com/questions/29153505/Powershell-Windows-Batch-Vbscript-move-files-based-on-contain.html
Solution proposed move log files from input to output if one file contains at least one line which doesn't start with 0.
Powershell approach:
$sourceFolder = 'C:\Temp\input'
$targetFolder = 'C:\Temp\output'
Get-ChildItem -Path $sourceFolder -Filter *.log |
Select-String -Pattern '^[^0]' -List |
ForEach-Object {Move-Item -Path $_.Path -Destination $targetFolder}
Batch approach:
for /f "tokens=*" %%A in ('findstr /m /b /v /c:"0;" "C:\TEMP\BASEDIR\*.log"') do move "%%A" "C:\TEMP\DESTDIR"
Additional need:
In input folder I have .log file and also it .csv file equivalent example : ReqXXXX.log and ReqXXXX.csv,
I would like:
-move log file in output (as is)
-move csv file equivalent into an output2 folder
Assumption:
-Every log file has it csv equivalent.
If you have questions, please contact me.
Thank you for your help.
EXPERT CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much for your help!