Knowledge
  • Read Me
  • Programming
    • ASP.NET
      • .NET Libraries
      • ASP.NET Core
        • Helper
          • Encryption
          • CSV Helper
          • String Helper
        • Logging
          • Simple Serilog
        • Middlewares
          • IP Restrictions
          • Request Throttling
          • Request Logging
        • Console
          • Command Line with arguments
        • JSON
      • ASP.NET Framework
      • Testing
        • Resources
        • xUnit.net
      • Naming Conventions
      • REST API Guidelines
    • Database
      • SQL Style Guide
      • MSSQL
        • Installation
          • Install MSSQL on MacOS M1 (ARM64)
        • Looping
        • Table Valued Functions
        • Session State
        • SQL Cheat Sheet
        • Export Pipe Delimited CSV With cmdshell
      • Redis
        • Redis Installation on Mac OS
        • Redis Installation on Docker
    • Java
      • AWS SDK - SSM
      • mTLS HTTP Connection
      • Read Resource Files
    • Javascript
      • Javascript Libraries
    • Python
    • OpenSSL
      • One Way SSL & Two Way SSL
      • Common OpenSSL Commands
      • Create Self-Signed Certificate
    • Misc
      • Git Commands
      • Windows Commands
      • PowerShell Commands
      • Vulnerabilities Dependency Check
      • Replace Filename Command
      • JSON Web Token (JWT)
      • Rabbit MQ Message-Broker
      • Pandoc Convert Document
  • DevOps
    • What is DevOps
    • CI & CD
    • Azure DevOps
  • Tools
    • Development Tools
Powered by GitBook
On this page

Was this helpful?

  1. Programming
  2. Misc

Replace Filename Command

This is an example to replace "[天堂www.*.com]" in the video file name.

Create a rename.bat file with command below:

@echo off
Powershell.exe -executionpolicy remotesigned -File ./rename.ps1
# pause

Create a rename.ps1 file with command below:

# Replace [天堂www.*.com] from video file name
$stringToReplace = -join([regex]::Escape("[天堂"), "www.*.com", [regex]::Escape("]"))
ls *.avi,*.mp4,*.mkv | ren -NewName {$_.name -replace $stringToReplace,""}

Put both rename.bat and rename.ps1 in the video folder, click on the rename.bat and it will execute powershell command rename.ps1

Expected Result

  • [天堂www.abc.com]video_001.avi --> video_001.avi

  • [天堂www.abc.com]video_002.mp4 --> video_002.mp4

  • [天堂www.abc.com]video_003.mkv --> video_003.mkv

PreviousVulnerabilities Dependency CheckNextJSON Web Token (JWT)

Last updated 6 years ago

Was this helpful?