Frage

we are OCRing all our sales order in our office. Pdf files being Created based on captured Data. The files looks like these S123456.pdf, S239463.pdf. some times the OCR software "reads" the "S" as a "5". (files end up created as 5123456.pdf.) I am looking for a Batch file for a windows command prompt environment that would rename only the files with the first character that starts with "5", rename it the "S" and leaving the rest intact. preferred to it apply to all sub-folders. I google around tried to modify some examples.. Can't get them working.. Please help!

War es hilfreich?

Lösung 2

This should work - it will only echo the ren commands to the screen so if it looks ok then remove the echo

@echo off
setlocal enabledelayedexpansion
for /r %%a in (5*.pdf) do (
set "name=%%~nxa"
echo ren "%%a" "S!name:~1!
)

Andere Tipps

A simple wildcard rename will actually do exactly what you want:

ren 5*.pdf S*.pdf
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top