Skip to content

Commit

Permalink
Update Script
Browse files Browse the repository at this point in the history
- Add list menu (Now you can choose Barcode) * Sample enter number 2 for generate QRCode
- Support Barcode Code128 & QRCodeMobile
  • Loading branch information
chaiwat20180 authored Jan 26, 2024
1 parent d76ea41 commit 3f823b1
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
57 changes: 57 additions & 0 deletions AutoGenBarCode_V02/AutoGenBarCode.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
Write-Host "========================================================="
Write-Host "= 1. AutoGenBarCode with Code-128 ="
Write-Host "= 2. AutoGenBarCode with MobileQRCode ="
Write-Host "========================================================="
Write-Host "= Create By Chaiwat ="
Write-Host "= ="
Write-Host "= ="
Write-Host "= _____ _ _ _______ __ _______ ="
Write-Host "= / ____| | | | /\ |_ _\ \ / /\|__ __| ="
Write-Host "= | | | |__| | / \ | | \ \ /\ / / \ | | ="
Write-Host "= | | | __ | / /\ \ | | \ \/ \/ / /\ \ | | ="
Write-Host "= | |____| | | |/ ____ \ _| |_ \ /\ / ____ \| | ="
Write-Host "= \_____|_| |_/_/ \_\_____| \/ \/_/ \_\_| ="
Write-Host "= ="
Write-Host "= ="
Write-Host "========================================================="
$Select_Number = Read-Host -Prompt 'Please Select Number: '
$Code_Name = ""
switch($Select_Number){
1{$Code_Name = "Code128"}
2{$Code_Name = "MobileQRCode"}
Default {
Break
}
}
if($Code_Name += $null){
# Set baseUrl จากเว็บ barcode.tec-itใแนท
$baseUrl = "https://barcode.tec-it.com/barcode.ashx?data="

# รับค่ารายการจากไฟล์ list.txt หากไม่มีให้สร้างในโฟลเดอร์นั้น
$textFilePath = "list.txt"

# โฟลเดอร์ที่จะเซฟหากไม่มีจะทำการ Auto Create Folder ให้
$saveDirectory = "AutoGenBarCode"

# อ่านค่าในแต่ละบรรทัดใน list.txt
$lines = Get-Content $textFilePath

foreach ($line in $lines) {
# รวมลิงก์
$barcodeUrl = $baseUrl + $line + "&code="+ $Code_Name +"&translate-esc=on&dpi=360"

# เซฟไฟล์ภาพ
$imagePath = Join-Path $saveDirectory ($line + ".png")

# เช็คว่าถ้าไม่มีโฟลเดอร์จะทำการสร้างโฟลเดอร์ให้
if (-not (Test-Path $saveDirectory)) {
New-Item -ItemType Directory -Path $saveDirectory
}

# ดาวน์โหลดรูปภาพมาเซฟที่โฟลเดอร์
Invoke-WebRequest -Uri $barcodeUrl -OutFile $imagePath
}
}
else{
Write-Host "Wrong Number"
}
9 changes: 9 additions & 0 deletions AutoGenBarCode_V02/list.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
chaiwat
we
qweqwe
qweqwfadvz
vzv
zv
zf
aeq
eqeqwe

0 comments on commit 3f823b1

Please sign in to comment.