Skip to content

Instantly share code, notes, and snippets.

@grim-reapper
Forked from vizsumit/filename-to-txt.bat
Created January 31, 2024 05:11
Show Gist options
  • Save grim-reapper/dac94ea55b888d743275cb157d22c6b1 to your computer and use it in GitHub Desktop.
Save grim-reapper/dac94ea55b888d743275cb157d22c6b1 to your computer and use it in GitHub Desktop.
This script generates .txt caption files from .jpg file names
@echo off
for %%i in (*.jpg) do (
set filename=%%i
set caption_filename=%%~ni.txt
set caption=%%~ni
setlocal EnableDelayedExpansion
for /f "tokens=1 delims=()" %%a in ("!caption!") do (
set caption=%%a
)
for /f "tokens=* delims=0123456789()" %%b in ("!caption!") do (
set caption=%%b
)
echo !caption! > %%~ni.txt
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment