Skip to content

Instantly share code, notes, and snippets.

@shakir-abdo
Forked from vizsumit/filename-to-txt.bat
Created September 7, 2023 09:34
Show Gist options
  • Save shakir-abdo/0f42594fbccdef53dddcadfc34670956 to your computer and use it in GitHub Desktop.
Save shakir-abdo/0f42594fbccdef53dddcadfc34670956 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